Skip to content

Commit 80836ca

Browse files
authored
Merge pull request #4 from phipsonlab/bioconductor_review_update1
Changelog: * Moved data for vignettes to `inst/extdata` and update vignettes accordingly. * Added scripts to generate files in `inst/extdata` and a README to inst folder. * Updated qs object for vignettes to qs2 object. * Minor change in `runSuperCellCyto` to use `sprintf` to print warning message.
2 parents f631cc6 + be094af commit 80836ca

15 files changed

+478
-350
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ Suggests:
3333
testthat (>= 3.0.0),
3434
BiocSingular,
3535
bluster,
36-
qs,
3736
scater,
3837
scran,
3938
Seurat,
4039
SingleCellExperiment,
41-
BiocStyle
40+
BiocStyle,
41+
magick,
42+
qs2
4243
VignetteBuilder: knitr
4344
Config/testthat/edition: 3
4445
URL: https://phipsonlab.github.io/SuperCellCyto/
4546
BugReports: https://github.com/phipsonlab/SuperCellCyto/issues
46-

R/runSuperCellCyto.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ runSuperCellCyto <- function(
257257
if (n_pc > length(markers)) {
258258
warning(
259259
sprintf(
260-
"n_pc (%d) > number of markers (%d). Setting n_pc to %d.",
260+
"Requested n_pc (%d) > markers (%d). Setting n_pc to %d.",
261261
n_pc, length(markers), length(markers)
262262
)
263263
)

inst/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# README
2+
3+
Data in `extdata` folder are obtained from the following sources:
4+
5+
* `Data23_Panel3_base_NR4_Patient9.fcs` and
6+
`Data23_Panel3_base_R5_Patient15.fcs` are mass cytometry data from anti-PD1
7+
immunotherapy study by [Krieg et. al](https://doi.org/10.1038/nm.4466).
8+
FCS files are available from
9+
[FlowRepository](
10+
http://flowrepository.org/public_experiment_representations/1124).
11+
* `Levine_32dim_H1_sub.csv` and `Levine_32dim_H2_sub.csv` are mass cytometry
12+
data from AML study by
13+
[Levine et. al](https://doi.org/10.1016/j.cell.2015.05.047).
14+
* `Levine_32dim_seurat_sub.qs2` and `Levine_32dim_sce_sub.qs2` are
15+
Seurat object and SingleCellExperiment object containing subsampled
16+
mass cytometry data from AML study by
17+
[Levine et. al](https://doi.org/10.1016/j.cell.2015.05.047).
18+
19+
Scripts to generate the different formats of `Levine_32dim` dataset is stored
20+
in the `inst/scripts` directory of
21+
[SuperCellCyto](https://github.com/phipsonlab/SuperCellCyto) repo.

inst/extdata/Levine_32dim_H1_sub.csv

Lines changed: 118 additions & 117 deletions
Large diffs are not rendered by default.

inst/extdata/Levine_32dim_H2_sub.csv

Lines changed: 197 additions & 196 deletions
Large diffs are not rendered by default.
-202 KB
Binary file not shown.
256 KB
Binary file not shown.
-338 KB
Binary file not shown.
275 KB
Binary file not shown.

inst/scripts/make_levine_32dim.R

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
library(HDCytoData)
2+
library(data.table)
3+
library(qs2)
4+
5+
6+
sce <- Levine_32dim_SE()
7+
8+
# isolate data from H1 and H2 patients
9+
sce_H1 <- sce[rowData(sce)$patient_id == "H1", ]
10+
sce_H2 <- sce[rowData(sce)$patient_id == "H2", ]
11+
12+
# remove unassigned
13+
sce_H1 <- sce_H1[rowData(sce_H1)$population_id != "unassigned", ]
14+
sce_H2 <- sce_H2[rowData(sce_H2)$population_id != "unassigned", ]
15+
16+
# randomly select 200 cells from each patient
17+
set.seed(42)
18+
sce_H1_sub <- sce_H1[sample(nrow(sce_H1), 200), ]
19+
sce_H2_sub <- sce_H2[sample(nrow(sce_H2), 200), ]
20+
21+
# convert to data.table
22+
dt_H1_sub <- data.table(assay(sce_H1_sub, "exprs"))
23+
dt_H2_sub <- data.table(assay(sce_H2_sub, "exprs"))
24+
25+
# save them as csv files
26+
fwrite(dt_H1_sub, "inst/extdata/Levine_32dim_H1_sub.csv")
27+
fwrite(dt_H2_sub, "inst/extdata/Levine_32dim_H2_sub.csv")
28+
29+
30+
# create the sce object
31+
dt <- data.table(assay(sce, "exprs"))
32+
dt[, population_id := rowData(sce)$population_id]
33+
dt[, sample := rowData(sce)$patient_id]
34+
35+
# get 50 cells from each population and sample
36+
set.seed(42)
37+
n_cells <- 50
38+
sampled_dt <- dt[, .SD[sample(.N, min(.N, n_cells))], by = c("population_id", "sample")]
39+
40+
# assign cell id
41+
sampled_dt[, cell_id := paste0("cell_", .I)]
42+
43+
# create SCE object
44+
exprs_mat <- t(as.matrix(sampled_dt[, !c("population_id", "sample", "cell_id"), with = FALSE]))
45+
sce_sampled <- SingleCellExperiment::SingleCellExperiment(assays = list(counts = exprs_mat))
46+
SummarizedExperiment::colData(sce_sampled)$population <- sampled_dt$population_id
47+
SummarizedExperiment::colData(sce_sampled)$sample <- sampled_dt$sample
48+
SummarizedExperiment::colData(sce_sampled)$cell_id <- sampled_dt$cell_id
49+
colnames(sce_sampled) <- sampled_dt$cell_id
50+
51+
qs_save(sce_sampled, "inst/extdata/Levine_32dim_sce_sub.qs2")
52+
53+
54+
# create Seurat object
55+
seurat_obj <- Seurat::CreateSeuratObject(
56+
counts = exprs_mat,
57+
assay = "originalexp",
58+
)
59+
seurat_obj <- Seurat::AddMetaData(seurat_obj, metadata = sampled_dt[, .(population_id, sample, cell_id)])
60+
# rename patient_id to sample
61+
62+
63+
qs_save(seurat_obj, "inst/extdata/Levine_32dim_seurat_sub.qs2")
64+
65+
66+

0 commit comments

Comments
 (0)