knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width=10,
  fig.height=10
)
library(ELeFHAnt)
library(Matrix)
data("reference_PBMC")
data("query_PBMC")
reference = reference_PBMC
query = query_PBMC
query = NormalizeData(query)
query = FindVariableFeatures(query)
query = ScaleData(query)
query = RunPCA(query)
query = RunUMAP(query, dims = 1:20)
out.CelltypeAnnotation = CelltypeAnnotation(reference = reference, query = query, downsample = TRUE, downsample_to = 1000, validatePredictions = FALSE, annotationCol = "Celltype")

p1 = DimPlot(out.CelltypeAnnotation, group.by = "seurat_clusters", label = T, reduction = "umap", label.size = 6, repel = T) + NoLegend()
p2 = DimPlot(out.CelltypeAnnotation, group.by = "ELeFHAnt_Ensemble_CelltypePrediction", label = T, reduction = "umap", label.size = 6, repel = T) + NoLegend()
p3 = DimPlot(out.CelltypeAnnotation, group.by = "ELeFHAnt_RF_CelltypePrediction", label = T, reduction = "umap", label.size = 6, repel = T) + NoLegend()
p4 = DimPlot(out.CelltypeAnnotation, group.by = "ELeFHAnt_SVM_CelltypePrediction", label = T, reduction = "umap", label.size = 6, repel = T) + NoLegend()
p5 = DimPlot(out.CelltypeAnnotation, group.by = "ELeFHAnt_LR_CelltypePrediction", label = T, reduction = "umap", label.size = 6, repel = T) + NoLegend()
p1
p2
p3
p4
p5
out.DR = DeduceRelationship(reference1 = reference, reference2 = query, downsample = TRUE, downsample_to = 1000, selectvarfeatures = 2000, ntree = 500, annotationCol_ref1 = "Celltype", annotationCol_ref2 = "Celltype")

out.DR
reference$Celltypes = reference$Celltype
query$Celltypes = query$Celltype

out.LH = LabelHarmonization(seurat.objects = c(reference, query), perform_integration = TRUE, integrated.atlas = NULL, downsample = TRUE, downsample_to = 1000, npcs = 30, resolution = 0.8, validatePredictions = FALSE, selectanchorfeatures = 2000, ntree = 500, k.anchor = 5, k.filter = 200, k.score = 30, dims = 1:30, species = NULL, tissue = NULL, annotationCol = "Celltypes")

p1 = DimPlot(out.LH, group.by = "Celltypes", label = T, reduction = "umap", label.size = 6, repel = T) + NoLegend()
p2 = DimPlot(out.LH, group.by = "ELeFHAnt_Ensemble_HarmonizedCelltype", label = T, reduction = "umap", label.size = 6, repel = T) + NoLegend()
p1
p2
out.Benchmark = BenchmarkELeFHAnt(reference = reference, query = query, downsample = TRUE, downsample_to = 1000, selectvarfeatures = 2000, ntree = 500, annotationCol = "Celltype")

p1 = DimPlot(out.Benchmark, group.by = "ELeFHAnt_Ensemble_CelltypePrediction", label=T, repel = T, label.size = 6, reduction = "umap") + NoLegend() + ggtitle("ELeFHAnt Predictions")
p2 = DimPlot(out.Benchmark, group.by = "predicted.id", label=T, repel = T, label.size = 6, reduction = "umap") + NoLegend() + ggtitle("LabelTransfer Predictions")
p3 = DimPlot(out.Benchmark, group.by = "scpred_prediction", label=T, repel = T, label.size = 6, reduction = "umap") + NoLegend() + ggtitle("scPred Predictions")

p1
p2
p3


praneet1988/ELeFHAnt documentation built on July 20, 2022, 7:29 p.m.