[adegenet-forum] adegenet help - Fst for a single gene alignment

Joao Fontenelle de Araujo Freire da Silva jp.fontenelle at mail.utoronto.ca
Tue May 22 21:57:38 CEST 2018


I want to use a gene alignment of 185 individuals to calculate the pairwise Fst stats for them.


My initial plan was:


Import the alignment, transform to DNAbin, transform to genind, the use that file to calculate the pairwise Fst.


I have some questions:


To use the function 'pairwise.fst' from the package pegas, I need to have diploid genind object. However my genind file is haploid. How can I alter that? Do I need to use the "df2genind" function? If so, what is the proper way to convert the alignment into a data frame?


How can I alter the populations for each individual? Do I need an additional object/dataframe with the population info? And how can I perform such action? Through the 'setPop' function?


Please see the script as it follows and my alignment attached.


Thank you for your time


Cheers


JP


### Attempt to use 'adegenet' to calculate Fst of sanger alignments ###


require (adegenet)

require (pegas)

require (hierfstat)


#Set working directory


setwd("~/Documents/Lab/PhD/steatogenys/fst/")


#Import/read fasta alignment using fasta2DNAbin function

#Will read the alignment and transform into DNAbin, which is used

#To calculate Fst

# The important thing is that the alignment (dna) file has to be transformed into DNAbin file

#Note alignment has to be same size, and clean, for each seq.


ali <- fasta2DNAbin("atpcleanFULL_name.fas", chunk = 10)

    #chuck = how many seqs processed at a time


#Transform DNAbin file in a data.matrix


myali <- as.matrix(ali)


#transform DNAbin object into genind object, calculates alleles, etc.

    # CHECK ARGUMENTS, % of polymorphism, pops, etc.

obj <- DNAbin2genind(myali)


#Calculate pairwise Fst NOT WORKING

matFst <- pairwise.fst(obj)



------------

João Pedro Fontenelle


Dept. of Biological Sciences

Dept. of Physical and Environmental Sciences

University of Toronto Scarborough

Office S552

1265 Military Trail

M1C 1A4

Toronto, ON, Canada
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20180522/48d594c0/attachment.html>


More information about the adegenet-forum mailing list