Last updated: 2020-07-08
Checks: 7 0
Knit directory: cytomapper_publication/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20200602)
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 b0e748f. 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: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: data/PancreasData/.DS_Store
Ignored: data/PancreasData/pancreas_images.rds
Ignored: data/PancreasData/pancreas_masks.rds
Ignored: data/PancreasData/pancreas_sce.rds
Untracked files:
Untracked: data/PancreasData/CellSubset.zip
Unstaged changes:
Modified: .gitignore
Modified: analysis/_site.yml
Deleted: analysis/about.Rmd
Deleted: analysis/license.Rmd
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/01-LoadPancreasData.Rmd
) and HTML (docs/01-LoadPancreasData.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 | cb92024 | nilseling | 2020-07-03 | Finalized Figure 4 |
html | 2fbf302 | nilseling | 2020-06-02 | Re-compiled htmls |
Rmd | 7960caa | nilseling | 2020-06-02 | Compiled htmls of preprocessing steps |
html | 7960caa | nilseling | 2020-06-02 | Compiled htmls of preprocessing steps |
Rmd | cddc968 | nilseling | 2020-06-02 | Chenged header |
Rmd | c68803c | nilseling | 2020-06-02 | Restructured to workflowr poject |
library(S4Vectors)
library(SingleCellExperiment)
library(cytomapper)
Here, a subset of single-cell data, corresponding to 100 images from the full dataset is downloaded.
# Download the zipped folder image and unzip it
url.cells <- ("https://data.mendeley.com/datasets/cydmwsfztj/2/files/f1e3b8dc-56be-4172-bbc4-3a6f9de97563/CellSubset.zip?dl=1")
download.file(url.cells, destfile = "data/PancreasData/CellSubset.zip")
unzip("data/PancreasData/CellSubset.zip", exdir = "data/PancreasData")
file.remove("data/PancreasData/CellSubset.zip")
[1] TRUE
# Read-in the data
cells <- read.csv("data/PancreasData/CellSubset.csv", stringsAsFactors = FALSE)
# Order the dataset by ImageNumber and ObjectNumber
cells <- cells[order(cells$ImageNumber, cells$ObjectNumber), ]
# Download the zipped folder image and unzip it
url.image <- ("https://data.mendeley.com/datasets/cydmwsfztj/2/files/0b236273-d21b-4566-84a2-f1c56324a900/Image.zip?dl=1")
download.file(url.image, destfile = "data/PancreasData/Image.zip")
unzip("data/PancreasData/Image.zip", exdir = "data/PancreasData")
file.remove("data/PancreasData/Image.zip")
[1] TRUE
# Read-in the data
image <- read.csv("data/PancreasData/All_Image.csv", stringsAsFactors = FALSE)
# Download the zipped folder image and unzip it
url.celltypes <- ("https://data.mendeley.com/datasets/cydmwsfztj/2/files/59e8da72-5bfe-4289-b95b-28348a6e1222/CellTypes.zip?dl=1")
download.file(url.celltypes, destfile = "data/PancreasData/CellTypes.zip")
unzip("data/PancreasData/CellTypes.zip", exdir = "data/PancreasData")
file.remove("data/PancreasData/CellTypes.zip")
[1] TRUE
# Read-in the data
celltypes <- read.csv("data/PancreasData/CellTypes.csv", stringsAsFactors = FALSE)
# Download the zipped folder image and unzip it
url.donors <- ("https://data.mendeley.com/datasets/cydmwsfztj/2/files/9074990e-1b93-4c79-8c49-1db01a66398b/Donors.zip?dl=1")
download.file(url.donors, destfile = "data/PancreasData/Donors.zip")
unzip("data/PancreasData/Donors.zip", exdir = "data/PancreasData")
file.remove("data/PancreasData/Donors.zip")
[1] TRUE
# Read-in the data
donors <- read.csv("data/PancreasData/Donors.csv", stringsAsFactors = FALSE)
cell.metadata <- DataFrame(ImageNumber = cells$ImageNumber,
CellNumber = cells$ObjectNumber,
Pos_X = cells$Location_Center_X,
Pos_Y = cells$Location_Center_Y,
ParentIslet = cells$Parent_Islets,
ClosestIslet = cells$Parent_ExpandedIslets,
Area = cells$AreaShape_Area,
NbNeighbours = cells$Neighbors_NumberOfNeighbors_3)
image.metadata <- DataFrame(ImageNumber = image$ImageNumber,
ImageFullName = image$FileName_CleanStack,
slide = image$Metadata_Slide,
width = image$Width_CleanStack,
height = image$Height_CleanStack)
cell.metadata <- merge(cell.metadata, image.metadata, by="ImageNumber")
This information is used by cytomapper
to match single-cell data with images and masks
cell.metadata$ImageName <- sub("_a0_full_clean.tiff", "", cell.metadata$ImageFullName)
# Add cell ids to cell metadata (format: "ImageName_CellNumber")
cell.metadata$id <- paste(cell.metadata$ImageName, cell.metadata$CellNumber, sep="_")
# Merge cell metadata and cell type information
cell.metadata <- merge(cell.metadata,
celltypes[, c("id", "CellCat", "CellType")],
by="id")
cell.metadata <- merge(cell.metadata, donors, by="slide")
# Rows are ordered by ImageNumber and CellNumber
cell.metadata <- cell.metadata[order(cell.metadata$ImageNumber, cell.metadata$CellNumber), ]
# Cell ids are used as row names
rownames(cell.metadata) <- cell.metadata$id
The panel contains antibody-related metadata. The channel-mass file is used to match panel information and image stack slices.
# Import panel
url.panel <- ("https://data.mendeley.com/datasets/cydmwsfztj/2/files/2f9fecfc-b98f-4937-bc38-ae1b959bd74d/Panel.csv?dl=1")
download.file(url.panel, destfile = "data/PancreasData/panel.csv")
panel <- read.csv("data/PancreasData/panel.csv")
# Import channel-mass file
url.channelmass <- ("https://data.mendeley.com/datasets/cydmwsfztj/2/files/704312eb-377c-42e2-8227-44bb9aca0fb3/ChannelMass.csv?dl=1")
download.file(url.channelmass, destfile = "data/PancreasData/ChannelMass.csv")
channel.mass <- read.csv("data/PancreasData/ChannelMass.csv", header = FALSE)
# Match panel and stack slice information
panel <- panel[panel$full == 1,]
panel <- panel[match(channel.mass[,1], panel$MetalTag),]
# Add short protein names as panel rownames
rownames(panel) <- panel$shortname
Here, we import the mean intensity per cell
cur_counts <- cells[, grepl("Intensity_MeanIntensity_CleanStack", colnames(cells))]
channelNumber <- as.numeric(sub("^.*_c", "", colnames(cur_counts)))
cur_counts <- cur_counts[, order(channelNumber, decreasing = FALSE)]
sce <- SingleCellExperiment(assays = list(counts = t(as.matrix(cur_counts))))
exprs = asinh-transformed counts
assay(sce, "exprs") <- asinh(counts(sce)/1)
rownames(sce) <- rownames(panel)
colnames(sce) <- rownames(cell.metadata)
colData(sce) <- cell.metadata
rowData(sce) <- panel
sce
class: SingleCellExperiment
dim: 38 252059
metadata(0):
assays(2): counts exprs
rownames(38): H3 SMA ... Ir191 Ir193
rowData names(15): TubeNb MetalTag ... miCAT2 miCAT
colnames(252059): E02_1 E02_2 ... J34_1149 J34_1150
colData names(26): slide id ... Ethnicity BMI
reducedDimNames(0):
altExpNames(0):
saveRDS(sce, "data/PancreasData/pancreas_sce.rds")
file.remove("data/PancreasData/All_Image.csv",
"data/PancreasData/CellSubset.csv",
"data/PancreasData/CellTypes.csv",
"data/PancreasData/Donors.csv",
"data/PancreasData/panel.csv",
"data/PancreasData/ChannelMass.csv")
[1] TRUE TRUE TRUE TRUE TRUE TRUE
sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.5
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] cytomapper_1.1.1 EBImage_4.30.0
[3] SingleCellExperiment_1.10.1 SummarizedExperiment_1.18.1
[5] DelayedArray_0.14.0 matrixStats_0.56.0
[7] Biobase_2.48.0 GenomicRanges_1.40.0
[9] GenomeInfoDb_1.24.2 IRanges_2.22.2
[11] S4Vectors_0.26.1 BiocGenerics_0.34.0
[13] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 locfit_1.5-9.4 lattice_0.20-41
[4] fftwtools_0.9-8 png_0.1-7 rprojroot_1.3-2
[7] digest_0.6.25 R6_2.4.1 tiff_0.1-5
[10] backports_1.1.7 evaluate_0.14 ggplot2_3.3.1
[13] pillar_1.4.4 zlibbioc_1.34.0 rlang_0.4.6
[16] whisker_0.4 raster_3.1-5 Matrix_1.2-18
[19] rmarkdown_2.2 stringr_1.4.0 htmlwidgets_1.5.1
[22] RCurl_1.98-1.2 munsell_0.5.0 compiler_4.0.0
[25] httpuv_1.5.4 xfun_0.14 pkgconfig_2.0.3
[28] htmltools_0.4.0 tidyselect_1.1.0 gridExtra_2.3
[31] tibble_3.0.1 GenomeInfoDbData_1.2.3 codetools_0.2-16
[34] viridisLite_0.3.0 crayon_1.3.4 dplyr_1.0.0
[37] later_1.1.0.1 bitops_1.0-6 grid_4.0.0
[40] gtable_0.3.0 lifecycle_0.2.0 git2r_0.27.1
[43] magrittr_1.5 scales_1.1.1 stringi_1.4.6
[46] XVector_0.28.0 viridis_0.5.1 fs_1.4.1
[49] promises_1.1.1 sp_1.4-2 generics_0.0.2
[52] ellipsis_0.3.1 vctrs_0.3.1 RColorBrewer_1.1-2
[55] tools_4.0.0 glue_1.4.1 purrr_0.3.4
[58] jpeg_0.1-8.1 abind_1.4-5 yaml_2.2.1
[61] colorspace_1.4-1 knitr_1.28