Learn R Programming

strataG (version 2.4.905)

fscRead: Read fastsimcoal output

Description

Read arlequin formatted output or parameter estimation files generated by fastsimcoal

Usage

fscReadArp(
  p,
  sim = c(1, 1),
  marker = c("all", "snp", "microsat", "dna", "standard"),
  chrom = NULL,
  sep.chrom = FALSE,
  drop.mono = FALSE,
  as.genotypes = TRUE,
  one.col = FALSE,
  sep = "/",
  coded.snps = FALSE
)

fscReadParamEst(p)

fscReadSFS(p, sim = 1)

Arguments

p

list of fastsimcoal input parameters.

sim

one or two-element numberic vector giving the number of the simulation replicate (and sub-replicate) to read. For example, sim = c(3, 5) will attempt to read "<label>_3_5.arp".

marker

type of marker to return.

chrom

numerical vector giving chromosomes to return. If NULL all chromosomes are returned.

sep.chrom

return a list of separate chromosomes?

drop.mono

return only polymorphic loci?

as.genotypes

return data as genotypes? If FALSE, original haploid data is returned. If TRUE, individuals are created by combining sequential haplotypes based on the ploidy used to run the simulation.

one.col

return genotypes with one column per locus? If FALSE, alleles are split into separate columns and designated as ".1", ".2", etc. for each locus.

sep

character to use to separate alleles if one.col = TRUE.

coded.snps

return diploid SNPs coded as 0 (major allele homozygote), 1 (heterozygote), or 2 (minor allele homozygote). If this is TRUE and marker = "snp" (or only SNPs are present) and the data is diploid, genotypes will be returned with one column per locus.

Value

fscReadArp

Reads and parses Arlequin-formatted .arp output files created by fastsimcoal2. Returns a data frame of genotypes, with individuals created by combining haplotypes based on the stored value of ploidy specified when the simulation was run.

fscReadParamEst

Reads and parses files output from a fastsimcoal2 run conducted for parameter estimation. Returns a list of data frames and vectors containing the data from each file.

fscReadSFS

Reads site frequency spectra generated from fastsimcoal2. Returns a list of the marginal and joint SFS, the polymorphic sites, and the estimated maximum likelihood of the SFS."

References

Excoffier, L. and Foll, M (2011) fastsimcoal: a continuous-time coalescent simulator of genomic diversity under arbitrarily complex evolutionary scenarios Bioinformatics 27: 1332-1334. Excoffier, L., Dupanloup, I., Huerta-S<U+00E1>nchez, E., Sousa, V.C., and M. Foll (2013) Robust demographic inference from genomic and SNP data. PLOS Genetics, 9(10):e1003905. http://cmpg.unibe.ch/software/fastsimcoal2/

See Also

fsc.input, fscWrite, fscRun

Examples

Run this code
# NOT RUN {
#' # three demes with optional names
demes <- fscSettingsDemes(
  Large = fscDeme(10000, 10), 
  Small = fscDeme(2500, 10),
  Medium = fscDeme(5000, 3, 1500)
)

# four historic events
events <- fscSettingsEvents(
  fscEvent(event.time = 2000, source = 1, sink = 2, prop.migrants = 0.05),
  fscEvent(2980, 1, 1, 0, 0.04),
  fscEvent(3000, 1, 0),
  fscEvent(15000, 0, 2, new.size = 3)
 )
 
# four genetic blocks of different types on three chromosomes.  
genetics <- fscSettingsGenetics(
  fscBlock_snp(10, 1e-6, chromosome = 1),
  fscBlock_dna(10, 1e-5, chromosome = 1),
  fscBlock_microsat(3, 1e-4, chromosome = 2),
  fscBlock_standard(5, 1e-3, chromosome = 3)
)

params <- fscWrite(demes = demes, events = events, genetics = genetics)

# runs 100 replicates, converting all DNA sequences to 0/1 SNPs
# will also output the MAF site frequency spectra (SFS) for all SNP loci.
params <- fscRun(params, num.sim = 100, dna.to.snp = TRUE, num.cores = 3)

# extracting only microsattelite loci from simulation replicate 1
msats <- fscReadArp(params, marker = "microsat")

# read SNPs from simulation replicate 5 with genotypes coded as 0/1
snp.5 <- fscReadArp(params, sim = 1, marker = "snp", coded.snps = TRUE

# read SFS for simulation 20
sfs.20 <- fscReadSFS(params, sim = 20)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab