library(BiocStyle) knitr::opts_chunk$set(error=FALSE, message=FALSE, warning=FALSE)
First, we download the data from Mendeley.
library(BiocFileCache) bfc <- BiocFileCache("raw_data", ask=FALSE) cellData.url <- "https://data.mendeley.com/datasets/cydmwsfztj/2/files/4473bd0c-b617-4c79-8253-8d61fbe4e8e8/Cells.zip?dl=1" cellTypes.url <- "https://data.mendeley.com/datasets/cydmwsfztj/2/files/59e8da72-5bfe-4289-b95b-28348a6e1222/CellTypes.zip?dl=1" metadata.url <- "https://data.mendeley.com/datasets/cydmwsfztj/2/files/b0405cb9-2816-4bc9-9baa-16d0f509d873/Metadata.csv?dl=1" all.urls <- c(cellData.url, cellTypes.url, metadata.url) data.path <- bfcrpath(bfc, all.urls)
Now read it into our session.
library(tidyverse) temp <- file.path("temp/") dir.create(temp, recursive = TRUE) lapply(data.path, FUN=unzip, exdir=temp) # Read in datasets. allCells <- read_csv(file.path(temp, "All_Cells.csv")) celltype <- read_csv(file.path(temp, "CellTypes.csv")) meta <- read_csv(file.path(data.path[["BFC3"]]))
Now, we want to clean the data up a bit.
# Load libraries library(tidyverse) library(spicyR) # Clean celltype celltype <- celltype %>% mutate(imageID = core, ImageNumber = as.numeric(as.factor(celltype$core)), imageCellID = id, ObjectNumber = as.numeric(lapply(strsplit(id,"_"),function(x)x[2])), cellType = factor(CellType)) cells <- allCells %>% mutate(x = AreaShape_Center_X, y = AreaShape_Center_Y) %>% select(x,y,ImageNumber, ObjectNumber, starts_with("Intensity_MeanIntensity_CleanStack_"), starts_with("AreaShape_")) %>% inner_join(celltype, by = c("ImageNumber", "ObjectNumber")) cellExp <- SegmentedCells(as.data.frame(cells), intensityString = "Intensity_MeanIntensity_CleanStack_", morphologyString = "AreaShape_") meta$stage <- factor(as.character(meta$stage),levels = c("Non-diabetic", "Onset", "Long-duration")) meta <- meta %>% mutate(imageID = image) %>% select(-image) colnames(meta) <- paste0("phenotype_", colnames(meta)) meta <- meta %>% rename(imageID=phenotype_imageID) data <- as.data.frame(cellExp) data <- data %>% left_join(meta, by="imageID")
ExperimentHub
StoragePrepare all the files for storage on the ExperimentHub
.
path <- file.path("scSpatial", "Damond-Diabetes", "1.0") dir.create(path, showWarnings=FALSE, recursive=TRUE) saveRDS(data, file=file.path(path, "spatialCellData.rds"))
And get rid of the temporary folder and the cache.
unlink(temp, recursive = TRUE, force = TRUE) unlink("raw_data", recursive = TRUE, force = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.