Skip to content

Commit

Permalink
Merge branch 'something-new' of https://github.com/sweebinee/CSC into…
Browse files Browse the repository at this point in the history
… something-new
  • Loading branch information
sweebinee committed Mar 5, 2019
2 parents a75f7ec + e1a6164 commit 79e910e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
47 changes: 37 additions & 10 deletions CSC_BCSC_analysis-BC_Epithelial_cell_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Haematopoietic_stem_cells Macrophage Monocyte
12 34579

#다쓰면 데이터 너무커서 CIBERSORT에 안올라감 1/8 = 7593 CELL 정도 써야함 (500개이상이면 많은거)
#500개 random sampling
#300개 random sampling
#bulkRNA에서 쓴 gene만 보자
bulk = read.table(file="/storage2/Project/CSC/RNA/03_Deconvolution/CSC_RNA_TPM_rm0_HUGO_rmdup.txt", header=TRUE, stringsAsFactors=FALSE)
gene <- bulk$external_gene_name
Expand Down Expand Up @@ -106,13 +106,13 @@ for(i in 1:ncol(HP_ph)){
HP_ph[is.na(HP_ph)] <- 2
#write.table(HP_ph,'/storage2/Project/CSC/10X/DGIST_data02/pheno_sample.txt',sep = "\t", row.names=TRUE, col.names=FALSE)
#reduce tcell
tcell_list<-sample(colnames(HP_ph[,HP_ph["T_cell",]==1]),500)
B_list<-sample(colnames(HP_ph[,HP_ph["B_cell",]==1]),500)
DC_list<-sample(colnames(HP_ph[,HP_ph["Dendritic",]==1]),500)
Macro_list<-sample(colnames(HP_ph[,HP_ph["Macrophage",]==1]),500)
Mono_list<-sample(colnames(HP_ph[,HP_ph["Monocyte",]==1]),500)
Neutro_list<-sample(colnames(HP_ph[,HP_ph["Neutrophil",]==1]),500)
NK_list<-sample(colnames(HP_ph[,HP_ph["NK_cell",]==1]),500)
tcell_list<-sample(colnames(HP_ph[,HP_ph["T_cell",]==1]),200)
B_list<-sample(colnames(HP_ph[,HP_ph["B_cell",]==1]),200)
DC_list<-sample(colnames(HP_ph[,HP_ph["Dendritic",]==1]),200)
Macro_list<-sample(colnames(HP_ph[,HP_ph["Macrophage",]==1]),200)
Mono_list<-sample(colnames(HP_ph[,HP_ph["Monocyte",]==1]),200)
Neutro_list<-sample(colnames(HP_ph[,HP_ph["Neutrophil",]==1]),200)
NK_list<-sample(colnames(HP_ph[,HP_ph["NK_cell",]==1]),200)

BM_list<-colnames(HP_ph[,HP_ph["Bone_marrow_cells",]==1])
CMP_list<-colnames(HP_ph[,HP_ph["CMP",]==1])
Expand All @@ -123,7 +123,34 @@ Myelo_list<-colnames(HP_ph[,HP_ph["Myelocyte",]==1])
ProM_list<-colnames(HP_ph[,HP_ph["Pro-Myelocyte",]==1])

cell <- union(union(union(union(union(union(union(union(union(union(union(union(union(tcell_list,B_list),DC_list),Macro_list),Mono_list),Neutro_list),NK_list),BM_list),CMP_list),Erythro_list),GMP_list),Haema_list),Myelo_list),ProM_list)
#4109 cells
#4109 cells : 500
#2709 cells : 300
#1309 cells : 100
#2009 cells : 200

HP_ph_reduced<-HP_ph[,which(colnames(HP_ph) %in% cell)]
write.table(HP_ph_reduced,'/storage2/Project/CSC/10X/DGIST_data02/pheno_sample_reduced.txt',sep = "\t", row.names=TRUE, col.names=FALSE)
write.table(HP_ph_reduced,'/storage2/Project/CSC/10X/DGIST_data02/pheno_sample200_reduced.txt',sep = "\t", row.names=TRUE, col.names=FALSE)

for(i in 1:10){
tcell_list<-sample(colnames(HP_ph[,HP_ph["T_cell",]==1]),200)
B_list<-sample(colnames(HP_ph[,HP_ph["B_cell",]==1]),200)
DC_list<-sample(colnames(HP_ph[,HP_ph["Dendritic",]==1]),200)
Macro_list<-sample(colnames(HP_ph[,HP_ph["Macrophage",]==1]),200)
Mono_list<-sample(colnames(HP_ph[,HP_ph["Monocyte",]==1]),200)
Neutro_list<-sample(colnames(HP_ph[,HP_ph["Neutrophil",]==1]),200)
NK_list<-sample(colnames(HP_ph[,HP_ph["NK_cell",]==1]),200)
BM_list<-colnames(HP_ph[,HP_ph["Bone_marrow_cells",]==1])
CMP_list<-colnames(HP_ph[,HP_ph["CMP",]==1])
Erythro_list<-colnames(HP_ph[,HP_ph["Erythroblast",]==1])
GMP_list<-colnames(HP_ph[,HP_ph["GMP",]==1])
Haema_list<-colnames(HP_ph[,HP_ph["Haematopoietic_stem_cells",]==1])
Myelo_list<-colnames(HP_ph[,HP_ph["Myelocyte",]==1])
ProM_list<-colnames(HP_ph[,HP_ph["Pro-Myelocyte",]==1])
cell <- union(union(union(union(union(union(union(union(union(union(union(union(union(tcell_list,B_list),DC_list),Macro_list),Mono_list),Neutro_list),NK_list),BM_list),CMP_list),Erythro_list),GMP_list),Haema_list),Myelo_list),ProM_list)
HP_raw_non0_reduced <- HP_raw_non0[which(rownames(HP_raw_non0)%in%gene),which(colnames(HP_raw_non0) %in% cell)]
write.table(HP_raw_non0_reduced,paste0('/storage2/Project/CSC/10X/DGIST_data02/CIBERSORT_200/ref_sample200_reduced_',i,'.txt'),sep = "\t", row.names=TRUE, col.names=TRUE)
HP_ph_reduced<-HP_ph[,which(colnames(HP_ph) %in% cell)]
write.table(HP_ph_reduced,paste0('/storage2/Project/CSC/10X/DGIST_data02/CIBERSORT_200/pheno_sample200_reduced_',i,'.txt'),sep = "\t", row.names=TRUE, col.names=FALSE)
}


11 changes: 8 additions & 3 deletions bulkRNA_deconv_heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,22 @@ library(ggrepel)
for(i in 1:nrow(merge_mtx)){
rownames(merge_mtx)[i]<-paste0(merge_mtx$Var1[i],":",merge_mtx$Var2[i])
}

merge_mtx<-merge_mtx[-c(79:84),]

# Add text to the plot
.labs <- rownames(merge_mtx)
b <- ggplot(merge_mtx, aes(x = scRNA, y = Xcell))
b <- ggplot(merge_mtx, aes(x = scRNA, y = CIBERSORT))

png("CRITERIA_01_dot_scRNA_Xcell.png",width=800, height=600)
png("CRITERIA_03_dot_scRNA_CIBERSORT_noT.png",width=800, height=600)
b + xlim(0.001, 1)+ylim(0.001, 1)+
geom_point(aes(color = Var1)) +
geom_smooth(method='lm',se = FALSE, fullrange = TRUE)+
ggpubr::stat_cor(label.x = 0.003)+
geom_text_repel(aes(label = .labs, color = Var1), size = 3)+
scale_color_manual(values = c("#FF0000", "#FF5500","#FFAA00","#FFFF00","#AAFF00","#00FF2B","#00FFD4","#00D4FF","#00AAFF","#0055FF","#5500FF","#AA00FF","#FF00AA","#FF0055"))+
labs(title = "scRNA vs Xcell\n", color = "cellTypes\n")
labs(title = "scRNA vs CIBERSORT\n", color = "cellTypes\n")
dev.off()



0 comments on commit 79e910e

Please sign in to comment.