Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
##################################################
## Project: Label Transfer Cell Types, SCT & Integration
## Date: 26.05.2020
## Author: Nathalie
##################################################
# setwd("/net/PE1/raid1/LAURA/SC_ANALYSIS/markerGeneDefinition")
#
# library(scrattch.io, lib.loc="pkg_r")
# library(Seurat, lib.loc="pkg_r")
# library(dplyr)
# library(pryr, lib.loc="pkg_r")
# library(RColorBrewer)
setwd("~/Documents/PostmortemBrain/analysis/markerGeneDefinition")
library(Seurat)
library(dplyr)
library(pryr)
library(RColorBrewer)
### TRANSFER CELL TYPES FROM ALLAN BRAIN ATLAS ########################
data <- readRDS("pilot/data_object_sct_integrated.rds")
referenceAllan <- readRDS("allan_human/data_object_sct.rds")
#referenceAllan <- subset(referenceAllan, subclass_label!="Exclude")
# Find cell type transfer anchors
brain.anchors <- FindTransferAnchors(reference = referenceAllan,
query = data,
normalization.method = "SCT",
dims = 1:30)
ref1 <- referenceAllan$subclass_label
ref2 <- referenceAllan$cluster_label
rm(referenceAllan)
# Transfer labels from the 20 subclasses
predictions_subclass <- TransferData(anchorset = brain.anchors,
refdata = ref1)
predictions_subclass <- predictions_subclass$predicted.id
data <- AddMetaData(data,
metadata = predictions_subclass,
col.name = 'predictions_subclass')
# Transfer labels from the 141 clusters
predictions_cluster <- TransferData(anchorset = brain.anchors,
refdata = ref2)
predictions_cluster <- predictions_cluster$predicted.id
data <- AddMetaData(data,
metadata = predictions_cluster,
col.name = 'predictions_cluster')
saveRDS(data, file = "pilot/data_object_sct_integrated.rds")
# plot UMAPs
png("pilot/UMAP_labelTransfer_subclassAllan_sct_integrated.png")
DimPlot(data, reduction = "umap", group.by = "predictions_subclass",
cols = colorRampPalette(brewer.pal(9, "Set1"))(nlevels(as.factor(data$predictions_subclass))))
dev.off()
png("pilot/UMAP_labelTransfer_clusterAllan_sct_integrated.png", width = 2000, height = 1000)
DimPlot(data, reduction = "umap", group.by = "predictions_cluster",
cols = colorRampPalette(brewer.pal(9, "Set1"))(nlevels(as.factor(data$predictions_cluster))))
dev.off()
png("pilot/UMAP_louvainCluster_sct_integrated.png")
DimPlot(data, reduction = "umap", group.by = "seurat_clusters",
cols = colorRampPalette(brewer.pal(9, "Set1"))(nlevels(as.factor(data$seurat_clusters))))
dev.off()