Last chance! 50% off unlimited learning
Sale ends in
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)
An instance or path of the vcfR-class
object to be processed.
If TRUE
the output genotype data are in the form of a XSnpMatrix-class
object. Otherwise, they are in the form of a SnpMatrix-class
object.
If it is unspecified, the phasing status will be determined by checking the first entry in the gt slot of the vcfR object. If the first entry is also missing, the value will be set to FALSE
.
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.
A list which contains the following components:
A numeric vector of the reference positions of SNPs.
A character vector of IDs of the subjects which the returned genotype data belong to.
An object of SnpMatrix-class
/XSnpMatrix-class
containing genotype data.
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.
# NOT RUN {
# 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)
}
# }
Run the code above in your browser using DataLab