View source: R/vcfR2SnpMatrix.R
vcfR2SnpMatrix | R Documentation |
Convert a vcfR-class
object into a list composed of genetic distances, subject IDs, and a SnpMatrix-class
/XSnpMatrix-class
object.
vcfR2SnpMatrix(obj, phased = NULL, subjects = NULL)
obj |
An instance or path of the |
phased |
If |
subjects |
A character or factor containing subject IDs. If supplied, genotype info of only those subjects will be returned. This should be a subset of the sample IDs in the vcfR object. |
In order to let vcfR2SnpMatrix
function properly, the input vcfR-class
object is expected to be generated from a valid VCF file which contains only biallelic SNPs and includes a GT section.
A list which contains the following components:
genetic.distances |
A numeric vector of the reference positions of SNPs. |
subjectID |
A character vector of IDs of the subjects which the returned genotype data belong to. |
data |
An object of |
io_vcfR
, SnpMatrix-class
, XSnpMatrix-class
# Load the vcfR object -- requires vcfR if (requireNamespace("vcfR", quietly = TRUE)) { require(vcfR) data(vcfR_example) vcf <- vcf[8:12,] # Extract needed genotype information alist <- vcfR2SnpMatrix(vcf) # Draw a pairwise LD plot using the extracted data LDheatmap(alist$data, alist$genetic.distance) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.