Skip to content

Commit

Permalink
saves Tran et al 2021 k nuclei summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
metamaden committed Jan 16, 2024
1 parent bbae031 commit e45fe67
Show file tree
Hide file tree
Showing 4 changed files with 374 additions and 394 deletions.
100 changes: 45 additions & 55 deletions cohort1/.Rhistory
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ p_size=15, s_x=1, s_y=.8, s_width=.5,
filename="cellScaleFactors.png",
h_fill="#FCFCFC", p_color = "#111111", h_color = "#FF674F")
setwd("C:/Users/User/Documents/GitHub/deconvo_method-paper/cohort1")
setwd("..")
setwd("..")
load("./env/05_bulk/02_crossvalidate_script.RData")
# Filter results to within-reference condition only
dfp <- df.k2[df.k2$experiment.type=="shared.reference",]
dfp$preparation.type <- gsub(".*_", "", dfp$bulk.sample.condition)
dfp <- na.omit(dfp)
# new plot
new.plot.scatter <-
ggplot(dfp, aes(x = true.neuron, y = neuron, color = bulk.scale.type)) +
theme_bw() + geom_point(alpha = 0.5) + geom_abline(slope = 1, intercept = 0) +
facet_grid(experiment.type~assay.name.lutearg+s.set.label) +
xlab("Known") + ylab("Predicted") + xlim(0, 1) + ylim(0, 1) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
knitr::opts_chunk$set(fig.width=10, fig.height=10, echo = F)
libv <- c("ggplot2")
sapply(libv, library, character.only = T)
Expand Down Expand Up @@ -104,79 +118,55 @@ knitr::kable(data.dict)
new.plot.scatter <-
ggplot(dfp, aes(x = true.neuron, y = neuron, color = bulk.scale.type)) +
theme_bw() + geom_point(alpha = 0.5) + geom_abline(slope = 1, intercept = 0) +
facet_wrap(experiment.type*assay.name.lutearg~s.set.label) +
facet_grid(experiment.type~assay.name.lutearg+s.set.label) +
xlab("Known") + ylab("Predicted") + xlim(0, 1) + ylim(0, 1) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
new.plot.scatter
# new plot
new.plot.scatter <-
ggplot(dfp, aes(x = true.neuron, y = neuron, color = bulk.scale.type)) +
theme_bw() + geom_point(alpha = 0.5) + geom_abline(slope = 1, intercept = 0) +
facet_wrap(experiment.type+assay.name.lutearg~s.set.label) +
xlab("Known") + ylab("Predicted") + xlim(0, 1) + ylim(0, 1) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
setwd("..")
setwd("..")
new.plot.path <- "./figures/05_bulk/figs3a_scatter.jpg"
jpeg(new.plot.path, width = 7.5, height = 7, res = 400, units = "in")
new.plot.scatter
# new plot
new.plot.scatter <-
ggplot(dfp, aes(x = true.neuron, y = neuron, color = bulk.scale.type)) +
theme_bw() + geom_point(alpha = 0.5) + geom_abline(slope = 1, intercept = 0) +
facet_grid(experiment.type+assay.name.lutearg~s.set.label) +
xlab("Known") + ylab("Predicted") + xlim(0, 1) + ylim(0, 1) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
dev.off()
setwd("..")
setwd("..")
new.plot.path <- "./figures/05_bulk/figs3a_scatter.jpg"
jpeg(new.plot.path, width = 6, height = 6, res = 400, units = "in")
new.plot.scatter
# new plot
new.plot.scatter <-
ggplot(dfp, aes(x = true.neuron, y = neuron, color = bulk.scale.type)) +
theme_bw() + geom_point(alpha = 0.5) + geom_abline(slope = 1, intercept = 0) +
facet_grid(experiment.type~assay.name.lutearg+s.set.label) +
xlab("Known") + ylab("Predicted") + xlim(0, 1) + ylim(0, 1) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
dev.off()
setwd("..")
setwd("..")
new.plot.path <- "./figures/05_bulk/figs3a_scatter.jpg"
jpeg(new.plot.path, width = 7, height = 5.5, res = 400, units = "in")
new.plot.scatter
dev.off()
setwd("..")
setwd("..")
new.plot.path <- "./figures/05_bulk/figs3a_scatter.jpg"
jpeg(new.plot.path, width = 7.5, height = 7, res = 400, units = "in")
jpeg(new.plot.path, width = 8, height = 5.5, res = 400, units = "in")
new.plot.scatter
dev.off()
setwd("..")
setwd("..")
load("./env/05_bulk/02_crossvalidate_script.RData")
knitr::opts_chunk$set(fig.width=10, fig.height=10, echo = F)
libv <- c("ggplot2")
sapply(libv, library, character.only = T)
new.plot.path <- "./figures/05_bulk/figs3a_scatter.jpg"
jpeg(new.plot.path, width = 8, height = 5, res = 400, units = "in")
new.plot.scatter
dev.off()
setwd("..")
setwd("..")
load("./env/05_bulk/02_crossvalidate_script.RData")
dfp <- df.k2
# format plot data
dfp <- dfp[dfp$crossvalidation=="validation",]
dfp[dfp$s.set.label=="s.null",]$s.set.label <- "unscaled"
dfp[dfp$s.set.label=="s.manual",]$s.set.label <- "scaled"
dfp$experiment.type <- paste0("z_type : ", dfp$experiment.type)
dfp$bulk.sample.id <- gsub("c1", "c", dfp$bulk.sample.id)
dfp$bulk.sample.id <- gsub("k1", "k", dfp$bulk.sample.id)
dfp$bulk.sample.id <- gsub("o1", "o", dfp$bulk.sample.id)
# experiment conditions
dfp$bulk.sample.condition <- cd[dfp$bulk.sample.id,]$expt_condition
table(dfp$bulk.sample.condition)
dfp <- na.omit(dfp)
new.plot.scatter <- ggplot(dfp, aes(x = true.neuron, y = neuron)) +
theme_bw() + geom_point(alpha = 0.5) +
geom_abline(slope = 1, intercept = 0) +
facet_wrap(~s.set.label*experiment.type) + xlab("Known") +
ylab("Predicted") + xlim(0, 1) + ylim(0, 1) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
new.plot.path <- "./figures/05_bulk/figs3a_scatter.jpg"
jpeg(new.plot.path, width = 8, height = 4.5, res = 400, units = "in")
new.plot.scatter
new.plot.scatter <- ggplot(dfp, aes(x = true.neuron, y = neuron)) +
theme_bw() + geom_point(alpha = 0.5) +
geom_abline(slope = 1, intercept = 0) +
facet_grid(s.set.label~experiment.type) + xlab("Known") +
ylab("Predicted") + xlim(0, 1) + ylim(0, 1) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
dev.off()
setwd("..")
setwd("..")
new.plot.path <- "./figures/05_bulk/figs3a_scatter.jpg"
jpeg(new.plot.path, width = 8, height = 4, res = 400, units = "in")
new.plot.scatter
dev.off()
setwd("..")
setwd("..")
new.plot.path <- "./figures/05_bulk/figs2b_validate.jpg"
jpeg(new.plot.path, width = 4.5, height = 5, units = "in", res = 400)
new.plot.path <- "./figures/05_bulk/figs3a_scatter.jpg"
jpeg(new.plot.path, width = 8, height = 4.2, res = 400, units = "in")
new.plot.scatter
dev.off()
10 changes: 5 additions & 5 deletions cohort2/outputs/02_summaries/cohort2_nuclei_summaries.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
k,cellType,median_nuclei_per_sample,mean_nuclei_per_sample,sd_nuclei_per_sample,median_proportion_nuclei_per_sample,mean_proportion_nuclei_per_sample,sd_proportion_nuclei_per_sample,median_marker_library_size,mean_marker_library_size,sd_marker_library_size
k2,neuron,2176.5,2078.75,922.920180238199,0.665874128565984,0.627831690999206,0.164627022800621,186.275005011024,129,192.069766282185
k2,glial,1067.5,1128.66666666667,419.576048656332,0.334125871434016,0.372168309000794,0.164627022800621,107.204075605434,77,101.892617186566
k3,Inhib,558,554.090909090909,451.741176902317,0.125752364574377,0.168093277786039,0.146388486906233,308.952255947498,261,217.308741475141
k3,Excit,1819,1659.72727272727,791.794176653136,0.494908350305499,0.493756240943012,0.158568135189935,232.023114421866,195,193.732105594974
k3,glial,977,1072.63636363636,390.139019511577,0.305217119650109,0.338150481270949,0.120569714000566,141.515043647767,104,128.84792068759
k2,neuron,849,1322.667,920.012,0.452,0.377,0.177,324.413,296,164.115
k2,glial,2887,2399,1384.1,0.548,0.623,0.177,269.877,263,151.807
k3,Inhib,332,526.667,360.808,0.179,0.149,0.067,336.114,313,168.653
k3,Excit,517,796,559.376,0.273,0.227,0.11,316.671,286,160.61
k3,glial,2887,2399,1384.1,0.548,0.623,0.177,269.877,263,151.807
16 changes: 3 additions & 13 deletions cohort2/scripts/02_summaries/03_nuclei.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
#------
# load marker data
load("env/01_pseudobulk/01_k2_mrb_script.RData")

sceK2 <- list.sce.markers[["k2"]]
sceK3 <- list.sce.markers[["k3"]]
load("env/01_pseudobulk/01_k3_mrb_script.RData")

dfSummary <- function(sce,
sampleIdVariable = "donor",
Expand Down Expand Up @@ -78,18 +76,10 @@ dfSummary <- function(sce,
return(dfSummaries)
}

summaryK2 <- dfSummary(sceK2, "Sample", "k2", c("neuron", "glial"))
summaryK3 <- dfSummary(sceK3, "Sample", "k3", c("Inhib", "Excit", "glial"))
summaryK2 <- dfSummary(sce.k2, "donor", "k2", c("neuron", "glial"))
summaryK3 <- dfSummary(sce.k3, "donor", "k3", c("Inhib", "Excit", "glial"))
summaryTable <- rbind(summaryK2, summaryK3)

sce.mrb$Sample <- sce.mrb$donor
summaryK2 <- dfSummary(sce.mrb, "Sample", "k2", c("neuron", "glial"))
summaryK3 <- dfSummary(sce.mrb, "Sample", "k3", c("Inhib", "Excit", "glial"))

summaryK3 <- dfSummary(sceK3, "Sample", "k3", c("Inhib", "Excit", "glial"))
summaryTable <- rbind(summaryK2, summaryK3)


#-----
# save
#-----
Expand Down
Loading

0 comments on commit e45fe67

Please sign in to comment.