View source: R/FractionDifferingVariants.R
FractionDifferingVariants | R Documentation |
Custom distance function tailored for variant data in a vartrix-like format (0=no data, 1=reference allele, 2=alternate allele, 3=heterozygous). The distance is defined as the fraction of variants which do not match, among the variants which are covered in both cells/genotypes being compared.
FractionDifferingVariants(x)
x |
A (typically sparse) genotype matrix in vartrix conventions, with cells/samples as rows and variants as columns. |
A distance object (as in stats package) containing the distances between the cells/samples.
# Typically used as a custom distance in combination with RunMDS in order to compute a dimensionality reduction based on variants:
DefaultAssay(MySeuratObject) <- "VAR" # variant calls, sparse matrix with values 1,2,3 for ref/alt/heterozygous in vartrix conventions. Assuming VariableFeatures have been set to most informative variants for this assay.
MySeuratObject <- RunMDS(MySeuratObject,FractionDifferingVariants)
DimPlot(MySeuratObject, reduction="mds")
MySeuratObject <- RunUMAP(MySeuratObject,reduction="mds",dims=1:30)
DimPlot(MySeuratObject, reduction="umap")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.