Adding certain barcodes to metadata
0
0
Entering edit mode
4.6 years ago

I want to upload an excel file sheet that has certain barcodes that I would like to show on my umap. How do I go about adding the file and linking it to the metadata?

Below is my following code.

# set up the working directory
wd = "/home/PTX_AAC656
setwd(wd)

# load counts
# SD-52-JZ33 patient sample but aligned to both mouse and human
SD_52_JZ33.data <- Read10X(data.dir = "../PTX_AAC656/metadata/patient_sample/SD-52-JZ33/outs/filtered_feature_bc_matrix/")
BNM_human_only.data <- Read10X(data.dir = "../PTX_AAC656/metadata/human_only_alignment/SD-52-JZ33_BNM_5K/outs/filtered_feature_bc_matrix/")
BNL_human_only.data <- Read10X(data.dir = "../PTX_AAC656/metadata/human_only_alignment/SD-52-JZ33_BNL_5K/outs/filtered_feature_bc_matrix/")
BNL_mouse_only.data <- Read10X(data.dir = "../PTX_AAC656/metadata/mouse_only_alignment/SD-52-JZ33_BNL_5K/outs/filtered_feature_bc_matrix/")
BNM_mouse_only.data <- Read10X(data.dir = "../PTX_AAC656/metadata/mouse_only_alignment/SD-52-JZ33_BNM_5K/outs/filtered_feature_bc_matrix/")


   BNL_both.data <- Read10X(data.dir = "../AAC656/SD-52-JZ33_BNL_5K/outs/filtered_feature_bc_matrix/")
    BNM_both.data <- Read10X(data.dir = "../AAC656/SD-52-JZ33_BNM_5K/outs/filtered_feature_bc_matrix/")

setwd(wd)

# create the Seurat objects
SD_52_JZ33 <- CreateSeuratObject(counts = SD_52_JZ33.data, min.cells = 0, project = "human")
BNL_human_only <- CreateSeuratObject(counts = BNL_human_only.data, min.cells = 0, project = "human_alignment_ptx")
BNM_human_only <- CreateSeuratObject(counts = BNM_human_only.data, min.cells = 0, project = "human_alignment_ptx")
BNM_both_ptx <- CreateSeuratObject(counts = BNM_both.data, min.cells = 0, project = "human_mouse_alignment_ptx")
BNL_both_ptx <- CreateSeuratObject(counts = BNL_both.data, min.cells = 0, project = "human_mouse_alignment_ptx")
BNL_both_ptx$model = "mouse_human_alignment_ptx"
BNM_both_ptx$model = "mouse_human_alignment_ptx"
SD_52_JZ33$model = "patient_aligned_mouse_human"
BNM_human_only$model = "human_alignment_only_ptx"
BNL_human_only$model = "human_alignment_only_ptx"
BNL_both_ptx$model = "mouse_human_alignment_ptx"
BNM_both_ptx$model = "mouse_human_alignment_ptx"
BNM_mouse_only <- CreateSeuratObject(counts = BNM_mouse_only.data, min.cells = 0, project = "mouse_alignment_ptx")
BNL_mouse_only <- CreateSeuratObject(counts = BNL_mouse_only.data, min.cells = 0, project = "mouse_alignment_ptx")
BNL_mouse_only$model = "mouse_alignment_only_ptx"
BNM_mouse_only$model = "mouse_alignment_only_ptx"

# merge samples
mouse_human_patient <- merge(BNL_mouse_only, y = c(BNM_mouse_only, SD_52_JZ33), add.cell.ids = c("A", "B", "C"), project = "HTB2876")
human_ptx_human_patient <- merge(BNL_human_only, y = c(BNM_human_only, SD_52_JZ33), add.cell.ids = c("D", "E", "F"), project = "HTB2876")
ptx_human_patient.1 <- merge(BNL_both_ptx, y = c(BNM_both_ptx, SD_52_JZ33), add.cell.ids = c("G", "H", "I"), project = "HTB2876")

# mouse ptx model with patient
# mark the mito genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = mouse_human_patient), value = TRUE)
mouse_human_patient[["percent.mt"]] <- PercentageFeatureSet(mouse_human_patient, pattern = "^MT-")
mouse_human_patient[["log_nCount_RNA"]] <- log2(mouse_human_patient[["nCount_RNA"]]+1)

# remove cells with <200 RNA molecules, or >6000 molecules, or >30% mito
mouse_human_patient <- subset(mouse_human_patient, subset = nFeature_RNA > 200 & nFeature_RNA < 6000 & percent.mt < 30)
mouse_human_patient <- NormalizeData(mouse_human_patient, normalization.method = "LogNormalize", scale.factor = 10000)
mouse_human_patient <- FindVariableFeatures(mouse_human_patient, selection.method = "vst", nfeatures = 2000)
all.genes.mouse <- rownames(mouse_human_patient)
mouse_human_patient <- ScaleData(mouse_human_patient, features = VariableFeatures(object = mouse_human_patient), vars.to.regress = c("nCount_RNA"))
mouse_human_patient <- RunPCA(mouse_human_patient, features = VariableFeatures(object = mouse_human_patient))
mouse_human_patient <- FindNeighbors(mouse_human_patient, dims = 1:20)
mouse_human_patient <- FindClusters(mouse_human_patient, resolution = 0.4)
mouse_human_patient <- RunUMAP(mouse_human_patient, dims = 1:20)
DimPlot(mouse_human_patient, reduction = "umap", group.by = "model")

# human only alignment pix with patient 
# mark the mito genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = human_ptx_human_patient), value = TRUE)
human_ptx_human_patient[["percent.mt"]] <- PercentageFeatureSet(human_ptx_human_patient, pattern = "^MT-")
human_ptx_human_patient[["log_nCount_RNA"]] <- log2(human_ptx_human_patient[["nCount_RNA"]]+1)
human_ptx_human_patient <- subset(human_ptx_human_patient, subset = nFeature_RNA > 200 & nFeature_RNA < 6000 & percent.mt < 30)

# remove cells with <200 RNA molecules, or >6000 molecules, or >30% mito
human_ptx_human_patient <- NormalizeData(human_ptx_human_patient, normalization.method = "LogNormalize", scale.factor = 10000)
human_ptx_human_patient <- FindVariableFeatures(human_ptx_human_patient, selection.method = "vst", nfeatures = 2000)
all.genes.human.ptx <- rownames(human_ptx_human_patient)
human_ptx_human_patient <- ScaleData(human_ptx_human_patient, features = VariableFeatures(object = human_ptx_human_patient), vars.to.regress = c("nCount_RNA"))
human_ptx_human_patient <- RunPCA(human_ptx_human_patient, features = VariableFeatures(object = human_ptx_human_patient))
DimPlot(human_ptx_human_patient, reduction = "pca")
human_ptx_human_patient <- FindNeighbors(human_ptx_human_patient, dims = 1:20)
human_ptx_human_patient <- FindClusters(human_ptx_human_patient, resolution = 0.4)
human_ptx_human_patient <- RunUMAP(human_ptx_human_patient, dims = 1:20)
DimPlot(human_ptx_human_patient, reduction = "umap", group.by = "model")

# ptx and human
# mark the mito genes
mito.genes.ptx_patient <- grep(pattern = "^MT-", x = rownames(x = ptx_human_patient.1), value = TRUE)
ptx_human_patient.1[["percent.mt"]] <- PercentageFeatureSet(ptx_human_patient.1, pattern = "^MT-")
ptx_human_patient.1[["log_nCount_RNA"]] <- log2(ptx_human_patient.1[["nCount_RNA"]]+1)

# remove cells with <200 RNA molecules, or >6000 molecules, or >30% mito
ptx_human_patient.1 <- subset(ptx_human_patient.1, subset = nFeature_RNA > 200 & nFeature_RNA < 6000 & percent.mt < 30)
ptx_human_patient.1 <- NormalizeData(ptx_human_patient.1, normalization.method = "LogNormalize", scale.factor = 10000)
ptx_human_patient.1 <- FindVariableFeatures(ptx_human_patient.1, selection.method = "vst", nfeatures = 2000)
all.genes.both.patient.1 <- rownames(ptx_human_patient.1)
ptx_human_patient.1 <- ScaleData(ptx_human_patient.1, features = VariableFeatures(object = ptx_human_patient.1), vars.to.regress = c("nCount_RNA"))
ptx_human_patient.1 <- RunPCA(ptx_human_patient.1, features = VariableFeatures(object = ptx_human_patient.1))
ptx_human_patient.1 <- FindNeighbors(ptx_human_patient.1, dims = 1:20)
ptx_human_patient.1 <- FindClusters(ptx_human_patient.1, resolution = 0.4)
ptx_human_patient.1 <- RunUMAP(ptx_human_patient.1, dims = 1:20)

#run plots
DimPlot(ptx_human_patient.1, reduction = "umap", group.by = "model")
DimPlot(ptx_human_patient.1, reduction = "umap", label = "TRUE")
saveRDS(ptx_human_patient.1, file = "derived_data/PTX_human_2876_res04_6000g.rds")
DimPlot(ptx_human_patient.1, reduction = "umap", group.by = "model")
DimPlot(ptx_human_patient.1, reduction = "umap", label = TRUE, pt.size = 0.5) + NoLegend()
ptx_human_patient.1$clustering.idents <- Idents(object = ptx_human_patient.1)
Idents(ptx_human_patient.1) <- "clustering.idents"
new.cluster.ids <- c("Human PTX Tumor", "PTX Fibroblast", "Human Fibroblast", "PTX Macrophage", "Human PTX Tumor", "Human Mitochondrial", "Human Macrophage", "Human Endothelial", "Human T-cells", "Human PTX Tumor","Human Fibroblast", "PTX Fibroblast", "Human Tumor Ductal", "Human Acinar", "PTX Macrophage", "PTX Stellate", "PTX Endothelial")
names(new.cluster.ids) <- levels(ptx_human_patient.1)
ptx_human_patient.1 <- RenameIdents(ptx_human_patient.1, new.cluster.ids)
saveRDS(ptx_human_patient.1, file = "derived_data/PTX_human_2876_res04_6000g.rds")
p1 = DimPlot(ptx_human_patient.1, reduction = "umap", label = TRUE, pt.size = 0.5,  group.by = "clustering.idents") + NoLegend()
p2 = DimPlot(ptx_human_patient.1, reduction = "umap", label = TRUE, pt.size = 0.5) + NoLegend()
print(CombinePlots(plots = list(p1, p2)))
markers2 <- FindAllMarkers(ptx_human_patient.1, min.pct = 0.25, logfc.threshold = 0.25)
markers2 %>% group_by(cluster) %>% top_n(n = 2, wt = avg_logFC)
saveRDS(markers, file="derived_data/markers_HTB2876_PC20_res04_6000g.rds")

Part of my excel sheet

barcode muTaTionsTaTus
GAGATGGCACTAGGCC-1  G12V
CTGAGCGAGACTCAAA-1  G12V
TACCGGGGTCCGAAGA-1  G12V
TATACCTCATAGGCGA-1  G12V
CTGCCATGTATTGGCT-1  G12V
AGTGTTGTCAGGAGAC-1  G12V
AATGCCAAGCAGTACG-1  G12V
TTTGTTGAGGCTTCCG-1  G12V
ACAGAAATCCATTCGC-1  G12V
GTCATTTCAACTAGAA-1  G12V
GAGTGTTGTGAGATTA-1  G12V
TCTTGCGCATAACGGG-1  G12V
ACATCGATCGGCATCG-1  G12V
CATCCCACACACAGCC-1  G12V
GACAGCCGTAGCTGTT-1  G12V
CACAGATGTTAGGCCC-1  G12V
AACGGGATCACAACCA-1  G12V
seurat scrnaseq • 1.1k views
ADD COMMENT

Login before adding your answer.

Traffic: 2301 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6