I am pretty new to R. So I apologize for asking maybe a very basic question. Let's say I have a fasta file with sequence below:


Is there a function or method to calculate entropy for each column in R? I did some research and found a function that calculate entropy for Amino Acids but not for DNA nucleotides.

I would like to have the output be stored in a vector or in a list.

Thanks for the help in advance!

  • 1
    $\begingroup$ Hi what is the goal of your research? Entropy is a function of a given allele since you have variation, particularly indels this is not possible. With an indel position e.g. 4 now becomes position 3 (sequence_2) within an entropy calculation, so which column are you referirng to? I think you are confusing this with phylogenetic methods. $\endgroup$
    – M__
    Jun 27 '20 at 5:57
  • $\begingroup$ Hi Michael, I was able to get it to with some other people's help. But to answer your question, The MolecularEntropy function in R did exactly what wanted to. It calculated the entropy at each nucleotide position with aligned sequences. $\endgroup$
    – Xiaoxixi
    Jun 27 '20 at 15:26
  • $\begingroup$ okay, the blurb does say "Gaps are ignored on a site by site basis so the entropy values may have different number of observations among sites." It also needs sequences to be the same length ... I personally don't think it works with indels $\endgroup$
    – M__
    Jun 27 '20 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.