Last updated: 2022-02-22
Checks: 7 0
Knit directory: MelanomaIMC/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200728)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 73aa800. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rproj.user/
Ignored: Table_S4.csv
Ignored: code/.DS_Store
Ignored: code/._.DS_Store
Ignored: data/.DS_Store
Ignored: data/._.DS_Store
Ignored: data/data_for_analysis/
Ignored: data/full_data/
Unstaged changes:
Modified: .gitignore
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/Supp-Figure_3.rmd
) and HTML (docs/Supp-Figure_3.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 64e5fde | toobiwankenobi | 2022-02-16 | change order and naming of supp fig files |
Rmd | 588dbb1 | toobiwankenobi | 2022-02-06 | Figure Order |
Rmd | b20b6fb | toobiwankenobi | 2022-02-02 | update code for Supp Figures |
Rmd | 3da15db | toobiwankenobi | 2021-11-24 | changes for revision |
Rmd | c4e2793 | toobiwankenobi | 2021-08-04 | rearrange figure order to match pre-print |
html | 4109ff1 | toobiwankenobi | 2021-07-07 | delete html files and adapt gitignore |
html | 4affda4 | toobiwankenobi | 2021-04-14 | figure adaptations |
Rmd | 3203891 | toobiwankenobi | 2021-02-19 | change celltype names |
html | 3203891 | toobiwankenobi | 2021-02-19 | change celltype names |
Rmd | ee1595d | toobiwankenobi | 2021-02-12 | clean repo and adapt files |
html | ee1595d | toobiwankenobi | 2021-02-12 | clean repo and adapt files |
html | 3f5af3f | toobiwankenobi | 2021-02-09 | add .html files |
Rmd | afa7957 | toobiwankenobi | 2021-02-08 | minor changes on figures and figure order |
Rmd | 20a1458 | toobiwankenobi | 2021-02-04 | adapt figure order |
Rmd | f9bb33a | toobiwankenobi | 2021-02-04 | new Figure 5 and minor changes in figure order |
Rmd | 73caa28 | toobiwankenobi | 2021-01-12 | minor corrections |
Rmd | 9442cb9 | toobiwankenobi | 2020-12-22 | add all new files |
Rmd | 1af3353 | toobiwankenobi | 2020-10-16 | add stuff |
Rmd | a6b51cd | toobiwankenobi | 2020-10-14 | clean scripts, add new subfigures |
This script generates plots for Supplementary Figure 3. It contains data that is not stored in the SCE format.
sapply(list.files("code/helper_functions", full.names = TRUE), source)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
code/helper_functions/calculateSummary.R
value ?
visible FALSE
code/helper_functions/censor_dat.R
value ?
visible FALSE
code/helper_functions/detect_mRNA_expression.R
value ?
visible FALSE
code/helper_functions/DistanceToClusterCenter.R
value ?
visible FALSE
code/helper_functions/findMilieu.R code/helper_functions/findPatch.R
value ? ?
visible FALSE FALSE
code/helper_functions/getInfoFromString.R
value ?
visible FALSE
code/helper_functions/getSpotnumber.R
value ?
visible FALSE
code/helper_functions/plotCellCounts.R
value ?
visible FALSE
code/helper_functions/plotCellFractions.R
value ?
visible FALSE
code/helper_functions/plotDist.R code/helper_functions/read_Data.R
value ? ?
visible FALSE FALSE
code/helper_functions/scatter_function.R
value ?
visible FALSE
code/helper_functions/sceChecks.R
value ?
visible FALSE
code/helper_functions/validityChecks.R
value ?
visible FALSE
library(SingleCellExperiment)
Loading required package: SummarizedExperiment
Loading required package: MatrixGenerics
Loading required package: matrixStats
Attaching package: 'matrixStats'
The following object is masked from 'package:dplyr':
count
Attaching package: 'MatrixGenerics'
The following objects are masked from 'package:matrixStats':
colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
colWeightedMeans, colWeightedMedians, colWeightedSds,
colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
rowWeightedSds, rowWeightedVars
Loading required package: GenomicRanges
Loading required package: stats4
Loading required package: BiocGenerics
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:dplyr':
combine, intersect, setdiff, union
The following objects are masked from 'package:stats':
IQR, mad, sd, var, xtabs
The following objects are masked from 'package:base':
anyDuplicated, append, as.data.frame, basename, cbind, colnames,
dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
union, unique, unsplit, which.max, which.min
Loading required package: S4Vectors
Attaching package: 'S4Vectors'
The following objects are masked from 'package:dplyr':
first, rename
The following objects are masked from 'package:base':
expand.grid, I, unname
Loading required package: IRanges
Attaching package: 'IRanges'
The following objects are masked from 'package:dplyr':
collapse, desc, slice
Loading required package: GenomeInfoDb
Loading required package: Biobase
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Attaching package: 'Biobase'
The following object is masked from 'package:MatrixGenerics':
rowMedians
The following objects are masked from 'package:matrixStats':
anyMissing, rowMedians
library(data.table)
Attaching package: 'data.table'
The following object is masked from 'package:SummarizedExperiment':
shift
The following object is masked from 'package:GenomicRanges':
shift
The following object is masked from 'package:IRanges':
shift
The following objects are masked from 'package:S4Vectors':
first, second
The following objects are masked from 'package:dplyr':
between, first, last
library(ggplot2)
library(dplyr)
library(stringr)
library(ggpubr)
library(ComplexHeatmap)
Loading required package: grid
========================================
ComplexHeatmap version 2.10.0
Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
Github page: https://github.com/jokergoo/ComplexHeatmap
Documentation: http://jokergoo.github.io/ComplexHeatmap-reference
If you use it in published research, please cite:
Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional
genomic data. Bioinformatics 2016.
The new InteractiveComplexHeatmap package can directly export static
complex heatmaps into an interactive Shiny app with zero effort. Have a try!
This message can be suppressed by:
suppressPackageStartupMessages(library(ComplexHeatmap))
========================================
library(circlize)
========================================
circlize version 0.4.13
CRAN page: https://cran.r-project.org/package=circlize
Github page: https://github.com/jokergoo/circlize
Documentation: https://jokergoo.github.io/circlize_book/book/
If you use it in published research, please cite:
Gu, Z. circlize implements and enhances circular visualization
in R. Bioinformatics 2014.
This message can be suppressed by:
suppressPackageStartupMessages(library(circlize))
========================================
library(gridExtra)
Attaching package: 'gridExtra'
The following object is masked from 'package:Biobase':
combine
The following object is masked from 'package:BiocGenerics':
combine
The following object is masked from 'package:dplyr':
combine
library(ggbeeswarm)
library(ggrepel)
library(ggpmisc)
Loading required package: ggpp
Attaching package: 'ggpp'
The following object is masked from 'package:ggplot2':
annotate
library(ggrastr)
library(readr)
library(cowplot)
Attaching package: 'cowplot'
The following object is masked from 'package:ggpubr':
get_legend
library(corrplot)
corrplot 0.92 loaded
library(rstatix)
Attaching package: 'rstatix'
The following object is masked from 'package:IRanges':
desc
The following object is masked from 'package:stats':
filter
# load data
cells1 = fread("data/data_for_analysis/12plex_validation/overexpression/20190305/cell.csv", header = T,sep=",")
cells2 = fread("data/data_for_analysis/12plex_validation/overexpression/20190306/cell.csv", header = T,sep=",")
meta1 = fread("data/data_for_analysis/12plex_validation/overexpression/20190305/Image.csv",header = T,sep=",")
meta2 = fread("data/data_for_analysis/12plex_validation/overexpression/20190306/Image.csv",header = T,sep=",")
panel = fread( "data/data_for_analysis/12plex_validation/overexpression/20190305/20190305_A431_overexpression.csv")
# extract replicate and stain info
meta1 = meta1[,.(ImageNumber,FileName_CellImage, Group_Number, Metadata_Target)]
meta1[,':=' (replicate = getInfoFromString(FileName_CellImage,"_",1)), by=ImageNumber]
meta2 = meta2[,.(ImageNumber,FileName_CellImage, Group_Number, Metadata_Target)]
meta2[,':=' (replicate = getInfoFromString(FileName_CellImage,"_",1)), by=ImageNumber]
# sort Metal Number in same order than in the Image.csv file
panel$`Metal Number` = str_extract(panel$`Metal Tag`, "[0-9]+")
panel = panel[order(panel$`Metal Number`),]
panel$channel = c(1:nrow(panel))
cells_long1 = melt.data.table(cells1,id.vars = c("ImageNumber", "ObjectNumber"),variable.factor = F)
cells_long2 = melt.data.table(cells2,id.vars = c("ImageNumber", "ObjectNumber"),variable.factor = F)
# create unique ID with Image and ObjectNumber
cells_long1[,id := paste(ImageNumber,ObjectNumber,sep ="_")]
cells_long2[,id := paste(ImageNumber,ObjectNumber,sep ="_")]
# multiply value by 2E16 since it divided by this number in CellProfiler
cells_long1$value = cells_long1$value * 65535
cells_long2$value = cells_long2$value * 65535
# calculate counts_asinh
cells_long1[,':=' (channel = as.integer(getInfoFromFileList(variable,sep="_",strPos = 4,censorStr = "c")),
counts_asinh = asinh(value/1)),
by=id]
cells_long2[,':=' (channel = as.integer(getInfoFromFileList(variable,sep="_",strPos = 4,censorStr = "c")),
counts_asinh = asinh(value/1)),
by=id]
# take only FullStack entries and not FullStackFiltered
cells_long1[,measurement:=getInfoFromString(variable,"_",3),by=variable]
cells_long1[,signal_type:=getInfoFromString(variable,"_",2),by=variable]
cells_long2[,measurement:=getInfoFromString(variable,"_",3),by=variable]
cells_long2[,signal_type:=getInfoFromString(variable,"_",2),by=variable]
unique(cells_long1$signal_type)
[1] "MeanIntensityCorrectedLS" "MeanIntensityCorrected"
[3] "MeanIntensity"
unique(cells_long2$signal_type)
[1] "MeanIntensityCorrectedLS" "MeanIntensityCorrected"
[3] "MeanIntensity"
cells1 = merge(cells_long1, meta1,by="ImageNumber")
cells2 = merge(cells_long2, meta2,by="ImageNumber")
cells = rbind(cells1, cells2)
# exclude some channels, make sure to exclude the right ones!
cells_panel = merge(cells,panel[,.(channel,Target, `Metal Tag`, `Metal Number`)],by="channel")
cells_panel = cells_panel[Target %in% c("T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12"),]
cells_panel = cells_panel[measurement != "FullStack",]
cells_panel = cells_panel[signal_type != "MeanIntensityCorrectedLS",]
unique(cells_panel$signal_type)
[1] "MeanIntensityCorrected" "MeanIntensity"
cells_panel_LScorrected = cells_panel[cells_panel$signal_type == "MeanIntensityCorrectedLS",]
cells_panel_uncorrected = cells_panel[cells_panel$signal_type == "MeanIntensity",]
cells_panel_corrected = cells_panel[cells_panel$signal_type == "MeanIntensityCorrected",]
results = matrix(nrow=12, ncol = 12)
rownames(results) = unique(cells_panel$Target)
colnames(results) = unique(cells_panel$Target)
results = as.data.frame(results)
cells_panel_corrected = as.data.frame(cells_panel_corrected)
# calculate percentage of unspecific binding
for(i in unique(cells_panel$Target)){
mean_target = mean(cells_panel_corrected[cells_panel_corrected["Metadata_Target"] == i & cells_panel_corrected["Target"] == i, "value"])
for(j in unique(cells_panel$Target)){
row_index = which(rownames(results) %in% i)
col_index = which(colnames(results) %in% j)
results[row_index, col_index] = mean(cells_panel_corrected[cells_panel_corrected["Metadata_Target"] == j & cells_panel_corrected["Target"] == i, "value"]) / mean_target * 100
}
}
# set crosstalk to 0 from one channel to same channel
results[results == 100] <- 0
a = Heatmap(as.matrix(results),
col = colorRamp2(c(0,1,3), c("white","blue", "red")),
row_order = order(as.numeric(gsub("T", "", unique(cells_panel_corrected$Target)))),
column_order = order(as.numeric(gsub("T", "", unique(cells_panel_corrected$Target)))),
heatmap_legend_param = list(title = "% cross-talk", size =15),
column_names_side = "top",
column_title = "Stained Channel",
row_title = "Other Channels",
row_names_side = "left",
column_names_rot = 0,
column_names_gp = gpar(fontsize = 15),
row_names_gp = gpar(fontsize = 15),
column_names_centered = T,
cell_fun = function(j, i, x, y, width, height, fill) {
grid.text(sprintf("%.1f", as.matrix(results)[i, j]), x, y, gp = gpar(fontsize = 10))
})
draw(a)
cells_panel2 <- cells_panel
cells_panel2[cells_panel2$signal_type == "MeanIntensity", ]$signal_type = "uncorrected"
cells_panel2[cells_panel2$signal_type == "MeanIntensityCorrected", ]$signal_type = "spill-over corrected"
ggplot(cells_panel2[cells_panel2$Metadata_Target == "T9",], aes(x=`Metal Tag`, y=counts_asinh, fill=signal_type)) +
geom_boxplot(outlier.shape = NA, lwd=0.5) +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
text = element_text(size=18)) +
guides(fill=guide_legend(title="Signal")) +
ylab("Mean Count (asinh)") +
xlab("") +
facet_wrap(~Metadata_Target,labeller = as_labeller(c(T9 = "mRNA Probe for Channel 9 (Er168)")))
rm(list = ls())
# Reload helper functions
sapply(list.files("code/helper_functions", full.names = TRUE), source)
code/helper_functions/calculateSummary.R
value ?
visible FALSE
code/helper_functions/censor_dat.R
value ?
visible FALSE
code/helper_functions/detect_mRNA_expression.R
value ?
visible FALSE
code/helper_functions/DistanceToClusterCenter.R
value ?
visible FALSE
code/helper_functions/findMilieu.R code/helper_functions/findPatch.R
value ? ?
visible FALSE FALSE
code/helper_functions/getInfoFromString.R
value ?
visible FALSE
code/helper_functions/getSpotnumber.R
value ?
visible FALSE
code/helper_functions/plotCellCounts.R
value ?
visible FALSE
code/helper_functions/plotCellFractions.R
value ?
visible FALSE
code/helper_functions/plotDist.R code/helper_functions/read_Data.R
value ? ?
visible FALSE FALSE
code/helper_functions/scatter_function.R
value ?
visible FALSE
code/helper_functions/sceChecks.R
value ?
visible FALSE
code/helper_functions/validityChecks.R
value ?
visible FALSE
cells1 = fread("data/data_for_analysis/12plex_validation/HeLa/20190208/cell.csv", header = T,sep=",")
cells3 = fread("data/data_for_analysis/12plex_validation/HeLa/20190215/cell.csv", header = T,sep=",")
cells4 = fread("data/data_for_analysis/12plex_validation/HeLa/20190222/cell.csv", header = T,sep=",")
meta1 = fread("data/data_for_analysis/12plex_validation/HeLa/20190208/Image.csv",header = T,sep=",")
meta3 = fread("data/data_for_analysis/12plex_validation/HeLa/20190215/Image.csv",header = T,sep=",")
meta4 = fread("data/data_for_analysis/12plex_validation/HeLa/20190222/Image.csv",header = T,sep=",")
meta1 = meta1[,.(ImageNumber,FileName_CellImage)]
meta3 = meta3[,.(ImageNumber,FileName_CellImage)]
meta4 = meta4[,.(ImageNumber,FileName_CellImage)]
meta1[,':=' (replicate = getInfoFromString(FileName_CellImage,"_",1),stain = getInfoFromString(FileName_CellImage,"_",6),
secondary_stain = getInfoFromString(FileName_CellImage,"_",7)),by=ImageNumber]
meta3[,':=' (replicate = getInfoFromString(FileName_CellImage,"_",1),stain = getInfoFromString(FileName_CellImage,"_",6),
secondary_stain = getInfoFromString(FileName_CellImage,"_",7)),by=ImageNumber]
meta4[,':=' (replicate = getInfoFromString(FileName_CellImage,"_",1),stain = getInfoFromString(FileName_CellImage,"_",7),
secondary_stain = getInfoFromString(FileName_CellImage,"_",8),
another_stain = getInfoFromString(FileName_CellImage,"_",6)),by=ImageNumber]
# rename positive stain
meta1[meta1$stain=="positive" & meta1$secondary_stain == "noAb",]$stain = "positive without Ab"
meta1[meta1$stain=="positive" & meta1$secondary_stain == "withAb",]$stain = "positive with Ab"
meta3[meta3$stain=="positive" & meta3$secondary_stain == "noAb",]$stain = "positive without Ab"
meta3[meta3$stain=="positive" & meta3$secondary_stain == "withAb",]$stain = "positive with Ab"
meta3[meta3$stain=="negative" & meta3$secondary_stain == "s0",]$stain = "negative 1st"
meta3[meta3$stain=="negative" & meta3$secondary_stain == "new",]$stain = "negative"
meta4[meta4$stain=="noAb",]$stain = "positive without Ab"
meta4[meta4$stain=="withAb",]$stain = "positive with Ab"
meta4[meta4$another_stain=="negative",]$stain = "negative"
meta4[meta4$another_stain=="T12",]$stain = "T12"
# change stain name
meta3[meta3$stain=="T7new",]$stain = "T7"
meta3[meta3$stain=="T5new",]$stain = "T5"
meta3[meta3$stain=="T11new",]$stain = "T11"
meta3[meta3$replicate =="20190221",]$replicate = "20190215"
panel = fread( "data/data_for_analysis/12plex_validation/HeLa/20190212_HeLa_12plex_validation.csv")
# sort Metal Number in same order than in the Image.csv file!!
panel$`Metal Number` = str_extract(panel$`Metal Tag`, "[0-9]+")
panel = panel[order(panel$`Metal Number`),]
panel$channel = c(1:nrow(panel))
# melt table
cells1_long = melt.data.table(cells1,id.vars = c("ImageNumber", "ObjectNumber"),variable.factor = F)
cells3_long = melt.data.table(cells3,id.vars = c("ImageNumber", "ObjectNumber"),variable.factor = F)
cells4_long = melt.data.table(cells4,id.vars = c("ImageNumber", "ObjectNumber"),variable.factor = F)
# multiply value by 2E16 since it divided by this number in CellProfiler
cells1_long$value = cells1_long$value * 65535
cells3_long$value = cells3_long$value * 65535
cells4_long$value = cells4_long$value * 65535
cells1_long[,id := paste(ImageNumber,ObjectNumber,sep ="_")]
cells1_long[,':=' (channel = as.integer(getInfoFromFileList(variable,sep="_",strPos = 4,censorStr = "c")),
counts_asinh = asinh(value/1)),
by=id]
cells3_long[,id := paste(ImageNumber,ObjectNumber,sep ="_")]
cells3_long[,':=' (channel = as.integer(getInfoFromFileList(variable,sep="_",strPos = 4,censorStr = "c")),
counts_asinh = asinh(value/1)),
by=id]
cells4_long[,id := paste(ImageNumber,ObjectNumber,sep ="_")]
cells4_long[,':=' (channel = as.integer(getInfoFromFileList(variable,sep="_",strPos = 4,censorStr = "c")),
counts_asinh = asinh(value/1)),
by=id]
# take only FullStack entries and not FullStackFiltered (not possible with RNA measurement, only with Ab's)
cells1_long[,measurement:=getInfoFromString(variable,"_",3),by=variable]
cells3_long[,measurement:=getInfoFromString(variable,"_",3),by=variable]
cells4_long[,measurement:=getInfoFromString(variable,"_",3),by=variable]
cells1_long = cells1_long[measurement=="FullStack",]
cells3_long = cells3_long[measurement=="FullStack",]
cells4_long = cells4_long[measurement=="FullStack",]
cells1_long = merge(cells1_long,meta1,by="ImageNumber")
cells3_long = merge(cells3_long,meta3,by="ImageNumber")
cells4_long = merge(cells4_long,meta4,by="ImageNumber")
# select only 1 negative measuremenet in 3th measurement
cells3_long = cells3_long[cells3_long$stain != "negative 1st", ]
# remove additional columns which are not needed
cells1_long = cells1_long[,!("secondary_stain")]
cells3_long = cells3_long[,!("secondary_stain")]
cells4_long = cells4_long[,!("secondary_stain")]
cells4_long = cells4_long[,!("another_stain")]
cells = rbind(cells1_long, cells3_long)
cells = rbind(cells, cells4_long)
# exclude certain channels, make sure to exclude the right ones!
cells_panel <- merge(cells,panel[,.(channel,Target)],by="channel")
cells_panel <- cells_panel[Target %in% c("T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12"),]
# import data from 8plex validation
cells_panel_8plex = readRDS(file = "data/data_for_analysis/12plex_validation/HeLa/2018_data_8plex_validation_DS.rds")
# make both data.frames same so they can be merged
cells_panel = cells_panel[, !("measurement")]
cells_panel_8plex = cells_panel_8plex[, !("AreaShape_Area")]
# rename the stains in the 8plex data
unique(cells_panel_8plex$stain)
[1] "C1" "C2" "C3" "C4" "C5" "C6" "C7" "C8"
[9] "all" "oldMix" "neg"
cells_panel_8plex = cells_panel_8plex[!(stain %in% ("oldMix")), ]
cells_panel_8plex[stain == "C1", ]$stain = "T1"
cells_panel_8plex[stain == "C2", ]$stain = "T4"
cells_panel_8plex[stain == "C3", ]$stain = "T3"
cells_panel_8plex[stain == "C4", ]$stain = "T8"
cells_panel_8plex[stain == "C5", ]$stain = "T12"
cells_panel_8plex[stain == "C6", ]$stain = "T2"
cells_panel_8plex[stain == "C7", ]$stain = "T9"
cells_panel_8plex[stain == "C8", ]$stain = "T6"
cells_panel_8plex[stain == "all", ]$stain = "positive with Ab"
cells_panel_8plex[stain == "neg", ]$stain = "negative"
cells_panel_8plex[Target == "C1", ]$Target = "T1"
cells_panel_8plex[Target == "C2", ]$Target = "T4"
cells_panel_8plex[Target == "C3", ]$Target = "T3"
cells_panel_8plex[Target == "C4", ]$Target = "T8"
cells_panel_8plex[Target == "C5", ]$Target = "T12"
cells_panel_8plex[Target == "C6", ]$Target = "T2"
cells_panel_8plex[Target == "C7", ]$Target = "T9"
cells_panel_8plex[Target == "C8", ]$Target = "T6"
# check
unique(cells_panel_8plex$stain)
[1] "T1" "T4" "T3" "T8"
[5] "T12" "T2" "T9" "T6"
[9] "positive with Ab" "negative"
unique(cells_panel_8plex$Target)
[1] "T1" "T4" "T3" "T8" "T12" "T2" "T9" "T6"
all(colnames(cells_panel) == colnames(cells_panel_8plex))
[1] TRUE
# merge both files
cells_panel_12plex = rbind(cells_panel, cells_panel_8plex)
# subset
cells_panel_12plex_sub = cells_panel_12plex[stain == Target,]
# relevel factor
cells_panel_12plex_sub$Target <- factor(cells_panel_12plex_sub$Target, levels = c("T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12"))
# check out difference in signal intensity for PPIB in the different channels
ggplot(data = cells_panel_12plex_sub[Target %in%c("T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12"),], aes(x=as.factor(Target),y=counts_asinh)) +
geom_boxplot(fill="deepskyblue1")+
theme_minimal()+
theme(text = element_text(size=25), axis.text.x = element_text(angle = 90, hjust = 1)) +
ylab("Mean Intensity Count per Cell [asinh]") +
xlab("Target Channels") +
geom_hline(yintercept = mean(cells_panel_12plex_sub$counts_asinh), linetype = 2) +
scale_x_discrete(breaks=c("T1", "T2", "T3","T4","T5","T6","T7","T8", "T9", "T10","T11", "T12"),
labels= c("T1 PPIB","T2 PPIB","T3 PPIB", "T4 PPIB", "T5 PPIB","T6 PPIB","T7 PPIB","T8 PPIB","T9 PPIB","T10 PPIB", "T11 PPIB", "T12 PPIB"))
cells_panel_12plex_sub %>%
group_by(stain) %>%
summarize(mean_per_channel = mean(counts_asinh)) %>%
mutate(sd = sd(mean_per_channel), mean = mean(mean_per_channel), min = min(mean_per_channel), max = max(mean_per_channel))
# A tibble: 12 × 6
stain mean_per_channel sd mean min max
<chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 T1 1.58 0.195 1.48 1.14 1.77
2 T10 1.44 0.195 1.48 1.14 1.77
3 T11 1.14 0.195 1.48 1.14 1.77
4 T12 1.68 0.195 1.48 1.14 1.77
5 T2 1.68 0.195 1.48 1.14 1.77
6 T3 1.38 0.195 1.48 1.14 1.77
7 T4 1.64 0.195 1.48 1.14 1.77
8 T5 1.21 0.195 1.48 1.14 1.77
9 T6 1.37 0.195 1.48 1.14 1.77
10 T7 1.77 0.195 1.48 1.14 1.77
11 T8 1.48 0.195 1.48 1.14 1.77
12 T9 1.39 0.195 1.48 1.14 1.77
dd = cells_panel[stain == "positive without Ab" | stain == "positive with Ab",]
# relevel factor
dd$Target <- factor(dd$Target, levels = c("T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12"))
dd$stain <- ifelse(dd$stain == "positive with Ab", "+ Antibodies", "- Antibodies")
# plot
ggplot(data=dd, aes(x=Target, y=counts_asinh, fill = stain)) +
geom_boxplot() +
scale_x_discrete(breaks=c("T1", "T2", "T3","T4","T5","T6","T7","T8", "T9", "T11","T10", "T12"),
labels= c("T1 POLR2A","T2 PPIB","T3 UBC", "T4 HPRT1", "T5 TUB","T6 RPL28","T7 RPL5","T8 B2M","T9 ACTB","T10 LDHA", "T11 RPLP0", "T12 GAPDH")) +
theme_minimal()+
theme(text = element_text(size=25), axis.text.x = element_text(angle = 90, hjust = 1)) +
ylab("Mean Intensity Count per Cell [asinh]") +
xlab("Target Channels") +
scale_fill_discrete(name = "Protocol Type")
# add gene name
cells_panel_12plex$gene <- ""
cells_panel_12plex[cells_panel_12plex$Target == "T1",]$gene <- "POLR2A"
cells_panel_12plex[cells_panel_12plex$Target == "T2",]$gene <- "PPIB"
cells_panel_12plex[cells_panel_12plex$Target == "T3",]$gene <- "UBC"
cells_panel_12plex[cells_panel_12plex$Target == "T4",]$gene <- "HPRT1"
cells_panel_12plex[cells_panel_12plex$Target == "T5",]$gene <- "TUB"
cells_panel_12plex[cells_panel_12plex$Target == "T6",]$gene <- "RPL28"
cells_panel_12plex[cells_panel_12plex$Target == "T7",]$gene <- "RPL5"
cells_panel_12plex[cells_panel_12plex$Target == "T8",]$gene <- "B2M"
cells_panel_12plex[cells_panel_12plex$Target == "T9",]$gene <- "ACTB"
cells_panel_12plex[cells_panel_12plex$Target == "T10",]$gene <- "LDHA"
cells_panel_12plex[cells_panel_12plex$Target == "T11",]$gene <- "RPLP0"
cells_panel_12plex[cells_panel_12plex$Target == "T12",]$gene <- "GAPDH"
median_per_gene <- cells_panel_12plex %>%
filter(stain == "positive with Ab") %>%
filter(replicate %in% c("20190208", "20190215", "20190222")) %>%
group_by(gene) %>%
summarise(expression_RNAScope = median(counts_asinh))
# data from human protein atlas
rna_seq <- data.frame(median_per_gene$gene)
colnames(rna_seq) <- "gene"
# load scRNA-seq data (downloaded from HPA, https://www.proteinatlas.org/about/download, Human Protein Atlas version 21.0)
HPA_data <- read.delim("data/data_for_analysis/HPA_rna_celline.tsv")
# HeLa cell line with genes-of-interest
HPA_data_sub <- HPA_data %>%
filter(Cell.line == "HeLa") %>%
filter(Gene.name %in% unique(cells_panel_12plex$gene))
colnames(HPA_data_sub) <- c("geneID", "gene", "cellline", "TPM", "pTPM", "nTPM")
# merge
sum <- left_join(median_per_gene, HPA_data_sub)
Joining, by = "gene"
# plot
ggplot(sum, aes(x=log2(nTPM), y=expression_RNAScope, label=gene)) +
geom_label_repel(size=7, fill="deepskyblue1", alpha=1,
min.segment.length = unit(0, 'lines'),
force_pull = 0) +
geom_point(size=3) +
geom_smooth(method = "lm") +
xlab("Normalized Expression RNA-Seq nTPM [log2]") +
ylab("Median Expression RNAScope [asinh]") +
stat_cor(method = "pearson",
aes(label = paste0("atop(", ..r.label.., ",", ..p.label.. ,")")),
size = 10, cor.coef.name = "R", label.sep="\n", label.y.npc = "top") +
theme_minimal() +
theme(text = element_text(size=20))
`geom_smooth()` using formula 'y ~ x'
Warning: Removed 1 rows containing non-finite values (stat_smooth).
Warning: Removed 1 rows containing non-finite values (stat_cor).
# correlation of the two technologies
sum_sub <- sum[sum$gene != "POLR2A",]
cor.test(sum_sub$expression_RNAScope, log2(sum_sub$nTPM), method = c("pearson"))
Pearson's product-moment correlation
data: sum_sub$expression_RNAScope and log2(sum_sub$nTPM)
t = 4.6597, df = 9, p-value = 0.001186
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.4861349 0.9576603
sample estimates:
cor
0.8408121
sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] grid stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] rstatix_0.7.0 corrplot_0.92
[3] cowplot_1.1.1 readr_2.1.2
[5] ggrastr_1.0.1 ggpmisc_0.4.5
[7] ggpp_0.4.3 ggrepel_0.9.1
[9] ggbeeswarm_0.6.0 gridExtra_2.3
[11] circlize_0.4.13 ComplexHeatmap_2.10.0
[13] ggpubr_0.4.0 stringr_1.4.0
[15] ggplot2_3.3.5 data.table_1.14.2
[17] SingleCellExperiment_1.16.0 SummarizedExperiment_1.24.0
[19] Biobase_2.54.0 GenomicRanges_1.46.1
[21] GenomeInfoDb_1.30.1 IRanges_2.28.0
[23] S4Vectors_0.32.3 BiocGenerics_0.40.0
[25] MatrixGenerics_1.6.0 matrixStats_0.61.0
[27] dplyr_1.0.7 workflowr_1.7.0
loaded via a namespace (and not attached):
[1] colorspace_2.0-2 ggsignif_0.6.3 rjson_0.2.21
[4] ellipsis_0.3.2 rprojroot_2.0.2 XVector_0.34.0
[7] GlobalOptions_0.1.2 fs_1.5.2 clue_0.3-60
[10] rstudioapi_0.13 farver_2.1.0 MatrixModels_0.5-0
[13] bit64_4.0.5 fansi_1.0.2 splines_4.1.2
[16] codetools_0.2-18 doParallel_1.0.16 knitr_1.37
[19] jsonlite_1.7.3 broom_0.7.12 cluster_2.1.2
[22] png_0.1-7 compiler_4.1.2 httr_1.4.2
[25] backports_1.4.1 assertthat_0.2.1 Matrix_1.4-0
[28] fastmap_1.1.0 cli_3.1.1 later_1.3.0
[31] htmltools_0.5.2 quantreg_5.87 tools_4.1.2
[34] gtable_0.3.0 glue_1.6.1 GenomeInfoDbData_1.2.7
[37] Rcpp_1.0.8 carData_3.0-5 jquerylib_0.1.4
[40] vctrs_0.3.8 nlme_3.1-155 iterators_1.0.13
[43] xfun_0.29 ps_1.6.0 lifecycle_1.0.1
[46] getPass_0.2-2 zlibbioc_1.40.0 scales_1.1.1
[49] hms_1.1.1 promises_1.2.0.1 parallel_4.1.2
[52] SparseM_1.81 RColorBrewer_1.1-2 yaml_2.2.2
[55] sass_0.4.0 stringi_1.7.6 highr_0.9
[58] foreach_1.5.2 shape_1.4.6 rlang_1.0.0
[61] pkgconfig_2.0.3 bitops_1.0-7 evaluate_0.14
[64] lattice_0.20-45 purrr_0.3.4 labeling_0.4.2
[67] bit_4.0.4 processx_3.5.2 tidyselect_1.1.1
[70] magrittr_2.0.2 R6_2.5.1 magick_2.7.3
[73] generics_0.1.2 DelayedArray_0.20.0 DBI_1.1.2
[76] mgcv_1.8-38 pillar_1.7.0 whisker_0.4
[79] withr_2.4.3 abind_1.4-5 RCurl_1.98-1.5
[82] tibble_3.1.6 crayon_1.4.2 car_3.0-12
[85] utf8_1.2.2 tzdb_0.2.0 rmarkdown_2.11
[88] GetoptLong_1.0.5 callr_3.7.0 git2r_0.29.0
[91] digest_0.6.29 tidyr_1.2.0 httpuv_1.6.5
[94] munsell_0.5.0 beeswarm_0.4.0 vipor_0.4.5
[97] bslib_0.3.1