This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to use the pegas package to calculate tajima D

Hello,

I try to use the package pegas of R for calculate the Dtajima, but I have a problem :

[data(Myexample)
Warning message:
In data(Myexample) : data set Myexample not found]

I used the tajima test : with a function "read.fasta"

require(ape)
data(Myexample)
tajima.test(Myexample)

My data is an alignment of 100 bacteria genoms.

In your opinion why it does not recognize my data ?

Thank you

tajima population genomics pegas r genome

I don't see the read.fasta() command.

Myexample<- read.FASTA(file="alignment_100.fasta_SNP.fasta")

1 answer

Do not use data( Myexample ):

require( pegas )
require( ape )
Myexample <- read.FASTA( file = "alignment_100.fasta_SNP.fasta" )
tajima.test( Myexample )

My files are genome sequences after doing an alignment.

My problem is that I divided my 100 genomes into 6 populations, and I would like to calculate the Dtajima for 6. Unfortunately I have this fault that I can not understand. enter link description here

Thank you

setwd("C:/Users/....") 
data=list() 
for(i in 1:6) {
data[[i]]=read.fasta(paste("pop",i,sep=""))
data
names(data[[i]]) = i
require(ape)
tajima.test(data[i])
}
Warning messages:
1: In tajima.test(data[i]) : Tajima test requires at least 4 sequences
2: In tajima.test(data[i]) : Tajima test requires at least 4 sequences
3: In tajima.test(data[i]) : Tajima test requires at least 4 sequences
4: In tajima.test(data[i]) : Tajima test requires at least 4 sequences
5: In tajima.test(data[i]) : Tajima test requires at least 4 sequences
6: In tajima.test(data[i]) : Tajima test requires at least 4 sequences

Log in to answer this question.