Last data update: 2014.03.03

R: Admixture coefficients from a snmf run
QR Documentation

Admixture coefficients from a snmf run

Description

Return the snmf output matrix of admixture coefficients for the chosen run with K ancestral populations. For an example, see snmf.

Usage

Q(object, K, run)

Arguments

object

A snmfProject object.

K

The number of ancestral populations.

run

A chosen run.

Value

res

A matrix containing the admixture coefficients for the chosen run with K ancestral populations.

Author(s)

Eric Frichot

See Also

geno snmf G cross.entropy

Examples

### Example of analyses using snmf ###

# creation of the genotype file, genotypes.geno.
# It contains 400 SNPs for 50 individuals.
data("tutorial")
write.geno(tutorial.R, "genotypes.geno")

################
# runs of snmf #
################

# main options, K: (the number of ancestral populations), 
#        entropy: calculate the cross-entropy criterion, 
#        CPU: the number of CPUs.

# Runs with K between 1 and 5 with cross-entropy and 2 repetitions.
project = NULL
project = snmf("genotypes.geno", K = 3, repetitions = 2, project = "new")

# get the ancestry coefficients for the 2nd run for K = 3. 
res = Q(project, K = 3, run = 2)

# plot the 2nd run for K = 3 (ancestry coefficients).
barplot(t(Q(project, K = 3, run = 2)))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LEA)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/LEA/Q.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Q
> ### Title: Admixture coefficients from a snmf run
> ### Aliases: Q
> ### Keywords: snmf
> 
> ### ** Examples
> 
> ### Example of analyses using snmf ###
> 
> # creation of the genotype file, genotypes.geno.
> # It contains 400 SNPs for 50 individuals.
> data("tutorial")
> write.geno(tutorial.R, "genotypes.geno")
[1] "genotypes.geno"
> 
> ################
> # runs of snmf #
> ################
> 
> # main options, K: (the number of ancestral populations), 
> #        entropy: calculate the cross-entropy criterion, 
> #        CPU: the number of CPUs.
> 
> # Runs with K between 1 and 5 with cross-entropy and 2 repetitions.
> project = NULL
> project = snmf("genotypes.geno", K = 3, repetitions = 2, project = "new")
The project is saved into :
 genotypes.snmfProject 

To load the project, use:
 project = load.snmfProject("genotypes.snmfProject")

To remove the project, use:
 remove.snmfProject("genotypes.snmfProject")

[1] "*************************************"
[1] "* sNMF K = 3  repetition 1      *"
[1] "*************************************"
summary of the options:

        -n (number of individuals)             50
        -L (number of loci)                    400
        -K (number of ancestral pops)          3
        -x (input file)                        /home/ddbj/DataUpdator-rgm3/target/genotypes.geno
        -q (individual admixture file)         /home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run1/genotypes_r1.3.Q
        -g (ancestral frequencies file)        /home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run1/genotypes_r1.3.G
        -i (number max of iterations)          200
        -a (regularization parameter)          10
        -s (seed random init)                  985477908
        -e (tolerance error)                   1E-05
        -p (number of processes)               1
        - diploid

Read genotype file /home/ddbj/DataUpdator-rgm3/target/genotypes.geno:		OK.


Main algorithm:
	[                                                                           ]
	[================]
Number of iterations: 43

Least-square error: 5655.573323
Write individual ancestry coefficient file /home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run1/genotypes_r1.3.Q:		OK.
Write ancestral allele frequency coefficient file /home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run1/genotypes_r1.3.G:	OK.

The project is saved into :
 genotypes.snmfProject 

To load the project, use:
 project = load.snmfProject("genotypes.snmfProject")

To remove the project, use:
 remove.snmfProject("genotypes.snmfProject")

[1] "*************************************"
[1] "* sNMF K = 3  repetition 2      *"
[1] "*************************************"
summary of the options:

        -n (number of individuals)             50
        -L (number of loci)                    400
        -K (number of ancestral pops)          3
        -x (input file)                        /home/ddbj/DataUpdator-rgm3/target/genotypes.geno
        -q (individual admixture file)         /home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run2/genotypes_r2.3.Q
        -g (ancestral frequencies file)        /home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run2/genotypes_r2.3.G
        -i (number max of iterations)          200
        -a (regularization parameter)          10
        -s (seed random init)                  279276518646641
        -e (tolerance error)                   1E-05
        -p (number of processes)               1
        - diploid

Read genotype file /home/ddbj/DataUpdator-rgm3/target/genotypes.geno:		OK.


Main algorithm:
	[                                                                           ]
	[====================================]
Number of iterations: 97

Least-square error: 5655.566886
Write individual ancestry coefficient file /home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run2/genotypes_r2.3.Q:		OK.
Write ancestral allele frequency coefficient file /home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run2/genotypes_r2.3.G:	OK.

The project is saved into :
 genotypes.snmfProject 

To load the project, use:
 project = load.snmfProject("genotypes.snmfProject")

To remove the project, use:
 remove.snmfProject("genotypes.snmfProject")

> 
> # get the ancestry coefficients for the 2nd run for K = 3. 
> res = Q(project, K = 3, run = 2)
Error in file(file, "rt") : cannot open the connection
Calls: Q ... Qvalues -> Qvalues -> as.matrix -> read.table -> file
In addition: Warning message:
In file(file, "rt") :
  cannot open file '/home/ddbj/DataUpdator-rgm3/target/genotypes.snmf/K3/run2/genotypes_r2.3.Q': No such file or directory
Execution halted