Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spatialData deprecation and missing 'outs/' directory #29

Merged
merged 4 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: spatialLIBD
Title: spatialLIBD: an R/Bioconductor package to visualize spatially-resolved
transcriptomics data
Version: 1.7.7
Date: 2022-01-07
Version: 1.7.8
Date: 2022-01-25
Authors@R:
c(
person("Leonardo", "Collado-Torres", role = c("aut", "cre"),
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ importFrom(S4Vectors,"mcols<-")
importFrom(S4Vectors,DataFrame)
importFrom(S4Vectors,mcols)
importFrom(S4Vectors,metadata)
importFrom(SpatialExperiment,"colData<-")
importFrom(SpatialExperiment,"imgData<-")
importFrom(SpatialExperiment,"spatialCoordsNames<-")
importFrom(SpatialExperiment,"spatialData<-")
importFrom(SpatialExperiment,SpatialImage)
importFrom(SpatialExperiment,addImg)
importFrom(SpatialExperiment,imgData)
Expand Down
6 changes: 3 additions & 3 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ app_server <- function(input, output, session) {
img <- SpatialExperiment::imgRaster(spe, sample_id = sampleid, image_id = input$imageid)

## From vis_gene() in global.R
d <- as.data.frame(colData(spe, spatialData = TRUE, spatialCoords = TRUE)[spe$sample_id == sampleid, ], optional = TRUE)
d <- as.data.frame(cbind(colData(spe), SpatialExperiment::spatialCoords(spe))[spe$sample_id == sampleid, ], optional = TRUE)
if (geneid %in% colnames(d)) {
d$COUNT <- d[[geneid]]
} else {
Expand Down Expand Up @@ -859,7 +859,7 @@ app_server <- function(input, output, session) {
}
if (!is.null(event.data)) {
## Prepare the data
d <- as.data.frame(colData(spe, spatialData = TRUE, spatialCoords = TRUE)[spe$key %in% event.data$key, ], optional = TRUE)
d <- as.data.frame(cbind(colData(spe), SpatialExperiment::spatialCoords(spe))[spe$key %in% event.data$key, ], optional = TRUE)
if (input$geneid %in% colnames(d)) {
d$COUNT <- d[[input$geneid]]
} else {
Expand Down Expand Up @@ -888,7 +888,7 @@ app_server <- function(input, output, session) {
)
} else {
## Prepare the data
d <- as.data.frame(colData(spe, spatialData = TRUE, spatialCoords = TRUE)[spe$key %in% event.data$key, ], optional = TRUE)
d <- as.data.frame(cbind(colData(spe), SpatialExperiment::spatialCoords(spe))[spe$key %in% event.data$key, ], optional = TRUE)
if (input$geneid %in% colnames(d)) {
d$COUNT <- d[[input$geneid]]
} else {
Expand Down
5 changes: 2 additions & 3 deletions R/sce_to_spe.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' [SpatialExperiment-class][SpatialExperiment::SpatialExperiment-class] object.
#' @export
#' @importFrom SpatialExperiment "imgData<-" "spatialCoordsNames<-"
#' "spatialData<-" SpatialImage
#' "colData<-" SpatialImage
#' @importFrom jsonlite read_json
#' @importFrom methods new
#' @family SpatialExperiment-related functions
Expand Down Expand Up @@ -166,11 +166,10 @@ sce_to_spe <- function(sce = fetch_data("sce"), imageData = NULL) {

spe <- SpatialExperiment::SpatialExperiment(
rowData = rowData_visium,
colData = colData_visium,
colData = cbind(colData_visium, spatialCoords_visium),
assays = assays_visium,
reducedDims = reducedDimNames_visium,
sample_id = NULL,
spatialData = spatialCoords_visium,
spatialCoordsNames = c("pxl_col_in_fullres", "pxl_row_in_fullres"),
scaleFactors = img_dat$scaleFactor,
imgData = img_dat,
Expand Down
2 changes: 1 addition & 1 deletion R/vis_clus.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ vis_clus <- function(spe,
point_size = 1.25,
...) {
spe_sub <- spe[, spe$sample_id == sampleid]
d <- as.data.frame(colData(spe_sub, spatialData = TRUE, spatialCoords = TRUE), optional = TRUE)
d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE)

vis_clus_p(
spe = spe_sub,
Expand Down
4 changes: 2 additions & 2 deletions R/vis_clus_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#'
#' @inheritParams vis_clus
#' @param d A data.frame with the sample-level information. This is typically
#' obtained using `colData(spe, spatialData = TRUE, spatialCoords = TRUE)`.
#' obtained using `cbind(colData(spe), spatialCoords(spe))`.
#' @param title The title for the plot.
#'
#' @return A [ggplot2][ggplot2::ggplot] object.
Expand All @@ -29,7 +29,7 @@
#' ## Don't plot the histology information
#' vis_clus_p(
#' spe = spe_sub,
#' d = as.data.frame(colData(spe_sub, spatialData = TRUE, spatialCoords = TRUE), optional = TRUE),
#' d = as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE),
#' clustervar = "layer_guess_reordered",
#' sampleid = "151673",
#' colors = libd_layer_colors,
Expand Down
2 changes: 1 addition & 1 deletion R/vis_gene.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ vis_gene <-
point_size = 1.25,
...) {
spe_sub <- spe[, spe$sample_id == sampleid]
d <- as.data.frame(colData(spe_sub, spatialData = TRUE, spatialCoords = TRUE), optional = TRUE)
d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE)

if (geneid %in% colnames(colData(spe_sub))) {
d$COUNT <- colData(spe_sub)[[geneid]]
Expand Down
4 changes: 2 additions & 2 deletions R/vis_gene_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' To visualize clusters (or any discrete variable) use [vis_clus_p()].
#'
#' @param d A data.frame with the sample-level information. This is typically
#' obtained using `colData(spe, spatialData = TRUE, spatialCoords = TRUE)`.
#' obtained using `cbind(colData(spe), spatialCoords(spe))`.
#' The data.frame has to contain
#' a column with the continuous variable data to plot stored under `d$COUNT`.
#' @inheritParams vis_clus_p
Expand All @@ -29,7 +29,7 @@
#'
#' ## Prepare the data for the plotting function
#' spe_sub <- spe[, spe$sample_id == "151673"]
#' df <- as.data.frame(colData(spe_sub, spatialData = TRUE, spatialCoords = TRUE), optional = TRUE)
#' df <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE)
#' df$COUNT <- df$expr_chrM_ratio
#'
#' ## Use the manual color palette by Lukas M Weber
Expand Down
4 changes: 2 additions & 2 deletions man/vis_clus_p.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/vis_gene_p.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vignettes/TenX_data_download.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ lymph.data <- sapply(lymph.url, BiocFileCache::bfcrpath, x = bfc)
```{r "extract_files"}
## Extract the files to a temporary location
## (they'll be deleted once you close your R session)
sapply(lymph.data, utils::untar, exdir = tempdir())
sapply(lymph.data, utils::untar, exdir = file.path(tempdir(), "outs"))

## List the files we downloaded and extracted
## These files are typically SpaceRanger outputs
lymph.dirs <- file.path(
tempdir(),
tempdir(), "outs",
c("filtered_feature_bc_matrix", "spatial", "raw_feature_bc_matrix", "analysis")
)
list.files(lymph.dirs)
Expand Down Expand Up @@ -440,7 +440,7 @@ To facilitate reading in the data and preparing it to visualize it interactively
```{r wrapper_functions}
## Import the data as a SpatialExperiment object
spe_wrapper <- read10xVisiumWrapper(
samples = tempdir(),
samples = file.path(tempdir(), "outs"),
sample_id = "lymph",
type = "sparse", data = "filtered",
images = c("lowres", "hires", "detected", "aligned"), load = TRUE,
Expand Down