# Calculate Entropy for DNA Multiple Sequence Alignment in R

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:

>sequence_1
ACCTGC--A
>sequence_2
ACC-GCTTA
>sequence_3
ACCTGCTTA


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!

• 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.
– M__
Jun 27 '20 at 5:57
• 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. Jun 27 '20 at 15:26
• 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
– M__
Jun 27 '20 at 15:29