Skip to content

Commit

Permalink
Merge pull request #17 from OSCA-source/scRNAseq-fixes
Browse files Browse the repository at this point in the history
Fixes for non-legacy data in scRNAseq
  • Loading branch information
lgeistlinger authored Apr 18, 2024
2 parents 7955fac + 8ce6ba6 commit 66bea5f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion inst/book/cell-cycle.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ library(scRNAseq)
sce.leng <- LengESCData(ensembl=TRUE)
# Performing a default analysis without any removal:
sce.leng <- logNormCounts(sce.leng, assay.type="normcounts")
sce.leng <- logNormCounts(sce.leng, assay.type="normalized")
dec.leng <- modelGeneVar(sce.leng)
top.hvgs <- getTopHVGs(dec.leng, n=1000)
sce.leng <- runPCA(sce.leng, subset_row=top.hvgs)
Expand Down
8 changes: 4 additions & 4 deletions inst/book/droplet-processing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ library(scRNAseq)
hto.sce <- StoeckiusHashingData(type="mixed")
hto.sce # The full dataset
altExp(hto.sce) # Contains the HTO counts
counts(altExp(hto.sce))[,1:3] # Preview of the count profiles
assay(altExp(hto.sce), "counts")[,1:3] # Preview of the count profiles
```

### Cell calling options
Expand Down Expand Up @@ -291,7 +291,7 @@ set.seed(10010)
# Setting lower= for correct knee point detection,
# as the coverage in this dataset is particularly low.
e.out.hto <- emptyDrops(counts(altExp(hto.sce)), by.rank=12000, lower=10)
e.out.hto <- emptyDrops(assay(altExp(hto.sce), "counts"), by.rank=12000, lower=10)
summary(is.cell.hto <- e.out.hto$FDR <= 0.001)
par(mfrow=c(1,2))
Expand Down Expand Up @@ -330,7 +330,7 @@ This reports the likely sample of origin for each library based on its most abun
For quality control, it returns the log-fold change between the first and second-most abundant HTOs in each barcode libary (Figure \@ref(fig:hto-1to2-hist)), allowing us to quantify the certainty of each assignment.

```{r hto-1to2-hist, fig.cap="Distribution of log-fold changes from the first to second-most abundant HTO in each cell."}
hto.mat <- counts(altExp(hto.sce))[,which(is.cell)]
hto.mat <- assay(altExp(hto.sce), "counts")[,which(is.cell)]
hash.stats <- hashedDrops(hto.mat)
hist(hash.stats$LogFC, xlab="Log fold-change from best to second HTO", main="")
```
Expand Down Expand Up @@ -372,7 +372,7 @@ e.g., if there are too few cells in the lower mode for accurate estimation of a
```{r hto-ambient2, fig.cap="Proportion of each HTO in the ambient solution for the cell line mixture data, estimated using the bimodal method in `hashedDrops()` or by computing the average abundance across all empty droplets (where the empty state is defined by using `emptyDrops()` on either the genes or the HTO matrix)."}
estimates <- rbind(
`Bimodal`=proportions(metadata(hash.stats)$ambient),
`Empty (genes)`=proportions(rowSums(counts(altExp(hto.sce))[,is.na(e.out.gene$FDR)])),
`Empty (genes)`=proportions(rowSums(assay(altExp(hto.sce), "counts")[,is.na(e.out.gene$FDR)])),
`Empty (HTO)`=metadata(e.out.hto)$ambient[,1]
)

Expand Down
2 changes: 1 addition & 1 deletion inst/book/more-hvgs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extractFromPackage("segerstolpe-pancreas.Rmd", package="OSCA.workflows",

```{r trend-plot-seger-noweight, fig.cap="Variance in the Segerstolpe pancreas data set as a function of the mean. Each point represents a gene while the lines represent the trend fitted to all genes with default parameters (blue) or without weights (red)."}
library(scran)
sce.seger <- sce.seger[,sce.seger$Donor=="HP1507101"]
sce.seger <- sce.seger[,sce.seger$Donor=="H4"]
dec.default <- modelGeneVar(sce.seger)
dec.noweight <- modelGeneVar(sce.seger, density.weights=FALSE)
Expand Down
7 changes: 4 additions & 3 deletions inst/book/protein-abundance.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ This can be easily achieved by running `runPCA()` without passing in a vector of
```{r}
library(scRNAseq)
sce.kotliarov <- KotliarovPBMCData()
adt.kotliarov <- altExp(sce.kotliarov)
# More convenient more subsequent steps have data as SCE than as an SE.
adt.kotliarov <- as(altExp(sce.kotliarov), "SingleCellExperiment")
adt.kotliarov
# QC.
Expand Down Expand Up @@ -666,7 +667,7 @@ This yields a number of gene/protein pairs with strong correlations - many of wh
# Using multiple core for speed.
library(BiocParallel)
blocked.correlations <- computeCorrelations(sce.main, altExp(sce.main),
block=clusters.adt, BPPARAM=MulticoreParam(4), use.names=c("Symbol", NA))
block=clusters.adt, BPPARAM=SerialParam(), use.names=c("Symbol", NA))
blocked.correlations[order(blocked.correlations$p.value),]
Expand All @@ -690,7 +691,7 @@ The example below will find the top 10 genes in the RNA data that are correlated
```{r}
set.seed(100) # For the IRLBA step.
top.correlations <- findTopCorrelations(x=altExp(sce.main), y=sce.main,
number=10, use.names=c(NA, "Symbol"), BPPARAM=MulticoreParam(4))
number=10, use.names=c(NA, "Symbol"), BPPARAM=SerialParam())
top.correlations$positive
```

Expand Down

0 comments on commit 66bea5f

Please sign in to comment.