Skip to content

Commit 3d5cf08

Browse files
Merge pull request #3 from snakemake-workflows/debug
Adapt to newest versions of scater, scran, and SingleCellExperiment.
2 parents 6a13e38 + 9da857e commit 3d5cf08

File tree

13 files changed

+27
-30
lines changed

13 files changed

+27
-30
lines changed

Snakefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ rule all:
3939
covariate=cells.columns[1:]),
4040
expand("plots/hvg-pca.{covariate}.svg",
4141
covariate=cells.columns[1:]),
42-
expand("plots/hvg-tsne.{covariate}.perp={perplexity}.seed={seed}.svg",
42+
expand("plots/hvg-tsne.{covariate}.seed={seed}.svg",
4343
covariate=cells.columns[1:],
44-
perplexity=[5, 10, 20],
4544
seed=[23213, 789789, 897354])
4645

4746

envs/eval.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
channels:
2-
- bioconda
32
- conda-forge
3+
- bioconda
44
dependencies:
5-
- bioconductor-scater =1.6
6-
- bioconductor-scran =1.6
7-
- bioconductor-singlecellexperiment =1.0
5+
- bioconductor-scater =1.10
6+
- bioconductor-scran =1.10
7+
- bioconductor-singlecellexperiment =1.4
88
- r-rcolorbrewer =1.1
9-
- bioconductor-rbgl =1.54
10-
- bioconductor-rgraphviz =2.22
9+
- bioconductor-rbgl =1.58
10+
- bioconductor-rgraphviz =2.26
1111
- r-gplots =3.0
12-
- bioconductor-limma =3.34
12+
- bioconductor-limma =3.38
1313
- r-rtsne =0.13
14+
- bioconductor-biomart =2.38

report/hvg-corr-tsne.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ where each point represents a cell.
33

44
Cells were colored by {{ snakemake.wildcards.covariate }}.
55
T-SNE visualizations can be misleading, due to parameter choices and the fact
6-
that it is non-deterministic. We therefore run t-SNE for different perplexities
7-
and random seeds.
8-
This plot shows results for perplexity={{ snakemake.wildcards.perplexity }} and
9-
seed={{ snakemake.wildcards.seed }}.
10-
T-SNE results will only be usable for you, if clustering is similar for different seeds.
6+
that it is non-deterministic. We therefore run t-SNE for different random seeds.
7+
This plot shows results for seed={{ snakemake.wildcards.seed }}.
8+
T-SNE results will only be usable for you if clustering is similar for different seeds.
119
See `here <https://distill.pub/2016/misread-tsne/>`_ for additional details.

rules/variance.smk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ rule hvg_tsne:
8080
sce="analysis/normalized.batch-removed.rds",
8181
var_cor="tables/hvg-correlations.tsv"
8282
output:
83-
report("plots/hvg-tsne.{covariate}.perp={perplexity}.seed={seed}.svg",
83+
report("plots/hvg-tsne.{covariate}.seed={seed}.svg",
8484
caption="../report/hvg-corr-tsne.rst",
8585
category="Dimension Reduction")
8686
params:
8787
fdr=config["model"]["fdr"]
8888
log:
89-
"logs/hvg-tsne.{covariate}.perp={perplexity}.seed={seed}.log"
89+
"logs/hvg-tsne.{covariate}.seed={seed}.log"
9090
conda:
9191
"../envs/eval.yaml"
9292
wildcard_constraints:

scripts/batch-effect-removal.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ model.vars <- colData(sce)
1616
model.vars$G1 <- cycle.assignments$scores$G1
1717
model.vars$G2M <- cycle.assignments$scores$G2M
1818

19-
2019
# setup design matrix
2120
model <- ~ 1
2221
for (variable in snakemake@params[["model_variables"]]) {
@@ -29,6 +28,6 @@ colnames(design) <- snakemake@params[["model_variables"]]
2928
saveRDS(design, file=snakemake@output[["design_matrix"]])
3029

3130
# remove batch effects based on variables
32-
batch.removed <- removeBatchEffect(exprs(sce), covariates=model.vars[, snakemake@params[["model_variables"]]])
33-
norm_exprs(sce) <- batch.removed
31+
batch.removed <- removeBatchEffect(logcounts(sce), covariates=model.vars[, snakemake@params[["model_variables"]]])
32+
logcounts(sce) <- batch.removed
3433
saveRDS(sce, file=snakemake@output[["sce"]])

scripts/cell-cycle.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (species == "mouse") {
2626
pairs <- readRDS(system.file("exdata", markers, package="scran"))
2727

2828
# obtain assignments
29-
assignments <- cyclone(sce, pairs, gene.names=rowData(sce)$feature_id)
29+
assignments <- cyclone(sce, pairs, gene.names=rowData(sce)$ensembl_gene_id)
3030

3131
# store assignments
3232
saveRDS(assignments, file=snakemake@output[[1]])

scripts/filter-cells.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ sce <- readRDS(snakemake@input[[1]])
1313

1414
# drop cells with too few counts or expressed features
1515
libsize.drop <- isOutlier(sce$total_counts, nmads=3, type="lower", log=TRUE)
16-
feature.drop <- isOutlier(sce$total_features, nmads=3, type="lower", log=TRUE)
16+
feature.drop <- isOutlier(sce$total_features_by_counts, nmads=3, type="lower", log=TRUE)
1717

1818
# drop cells with too high proportion of mito genes or spike-ins expressed
1919
mito.drop <- isOutlier(sce$pct_counts_Mt, nmads=3, type="higher")

scripts/hvg-correlation.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dev.off()
4242
# choose significantly correlated genes
4343
chosen <- unique(c(var.cor$gene1[sig.cor], var.cor$gene2[sig.cor]))
4444
# get normalized expressions
45-
norm.exprs <- exprs(sce)[chosen,,drop=FALSE]
45+
norm.exprs <- logcounts(sce)[chosen,,drop=FALSE]
4646

4747

4848
# plot heatmap

scripts/hvg-pca.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ style <- theme(
2424

2525
# plot PCA
2626
svg(file=snakemake@output[[1]])
27-
plotPCA(sce, colour_by=covariate,
28-
feature_set=chosen, ncomponents=3) + style
27+
plotPCA(sce[chosen, ], colour_by=covariate,
28+
ncomponents=3) + style
2929
dev.off()

scripts/hvg-tsne.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ library(scater)
1111
library(scran)
1212

1313
seed <- as.integer(snakemake@wildcards[["seed"]])
14-
perplexity <- as.integer(snakemake@wildcards[["perplexity"]])
1514
fdr <- snakemake@params[["fdr"]]
1615
covariate <- gsub("-", ".", snakemake@wildcards[["covariate"]])
1716

@@ -29,6 +28,5 @@ style <- theme(
2928
# plot t-SNE
3029
svg(file=snakemake@output[[1]])
3130
set.seed(seed)
32-
plotTSNE(sce, perplexity=perplexity,
33-
colour_by=covariate, feature_set=chosen) + style
31+
plotTSNE(sce[chosen, ], colour_by=covariate) + style
3432
dev.off()

0 commit comments

Comments
 (0)