Skip to content

Commit fcde6d7

Browse files
Merge pull request #694 from joshua-d-campbell/master
Merging from devel for new release 2.8.1
2 parents 654e1cc + 405e3da commit fcde6d7

File tree

547 files changed

+22485
-4524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

547 files changed

+22485
-4524
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ exec/png
1515
.covrignore
1616
^pkgdown$
1717
^\.github$
18+
^vignettes/articles/*
19+
^images

.github/workflows/BioC-check.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@ jobs:
3939
if: runner.os == 'macOS'
4040
run: brew install fftw
4141

42-
- uses: r-lib/actions/setup-r-dependencies@v1
42+
- name: Manual Install
43+
run: |
44+
install.packages("BiocManager")
45+
BiocManager::install("ggtree")
46+
shell: Rscript {0}
47+
48+
- uses: r-lib/actions/setup-r-dependencies@v2
4349
with:
4450
extra-packages: rcmdcheck
51+
cache-version: 2
4552

4653
- name: Install XQuartz on macOS
4754
if: runner.os == 'macOS'

.github/workflows/R-CMD-check.yaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ jobs:
2727
R_KEEP_PKG_SOURCE: yes
2828

2929
steps:
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
3131

32-
- uses: r-lib/actions/setup-pandoc@v1
32+
- uses: r-lib/actions/setup-pandoc@v2
3333

3434
- name: Setup Python
35-
uses: actions/setup-python@v2.2.2
35+
uses: actions/setup-python@v2
3636
with:
3737
python-version: '3.8'
3838

@@ -57,7 +57,7 @@ jobs:
5757
which python
5858
shell: bash
5959

60-
- uses: r-lib/actions/setup-r@v1
60+
- uses: r-lib/actions/setup-r@v2
6161
with:
6262
r-version: ${{ matrix.config.r }}
6363
http-user-agent: ${{ matrix.config.http-user-agent }}
@@ -71,16 +71,18 @@ jobs:
7171
if: runner.os == 'macOS'
7272
run: brew install fftw
7373

74-
- uses: r-lib/actions/setup-r-dependencies@v1
75-
with:
76-
extra-packages: rcmdcheck
77-
78-
- name: Install Celda devel
74+
- name: Manual Install
7975
run: |
80-
install.packages("devtools")
81-
devtools::install_github("campbio/celda@devel")
76+
install.packages("BiocManager")
77+
BiocManager::install("ggtree")
8278
shell: Rscript {0}
8379

80+
- uses: r-lib/actions/setup-r-dependencies@v2
81+
with:
82+
cache-version: 2
83+
extra-packages: any::rcmdcheck
84+
needs: check
85+
8486
- name: Install XQuartz on macOS
8587
if: runner.os == 'macOS'
8688
run: brew install xquartz --cask

DESCRIPTION

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
Package: singleCellTK
22
Type: Package
33
Title: Comprehensive and Interactive Analysis of Single Cell RNA-Seq Data
4-
Version: 2.8.0
4+
Version: 2.8.1
55
Authors@R: c(person(given="Yichen", family="Wang", email="wangych@bu.edu", role=c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-4347-5199")),
77
person(given="Irzam", family="Sarfraz", email="isarfraz@bu.edu", role=c("aut"),
88
comment = c(ORCID = "0000-0001-8121-792X")),
99
person(given="Rui", family="Hong", email="rzhong@bu.edu", role=c("aut")),
1010
person(given="Yusuke", family="Koga", email="ykoga07@bu.edu", role=c("aut")),
1111
person(given="Salam", family="Alabdullatif", email="salamha@bu.edu", role=c("aut")),
12+
person(given="Nida", family="Pervaiz", email="nidapervaiz27@gmail.com", role=c("aut")),
1213
person(given="David", family="Jenkins", email="dfj@bu.edu", role=c("aut"),
1314
comment = c(ORCID = "0000-0002-7451-4288")),
1415
person(given="Vidya", family="Akavoor", email="vidyaap@bu.edu", role=c("aut")),
@@ -64,7 +65,7 @@ Imports:
6465
KernSmooth,
6566
limma,
6667
MAST,
67-
Matrix,
68+
Matrix (>= 1.5-3),
6869
matrixStats,
6970
methods,
7071
msigdbr,
@@ -94,7 +95,7 @@ Imports:
9495
reticulate (>= 1.14),
9596
tools,
9697
tximport,
97-
fishpond,
98+
eds,
9899
withr,
99100
GSEABase,
100101
R.utils,
@@ -113,8 +114,9 @@ Imports:
113114
TrajectoryUtils,
114115
scuttle,
115116
utils,
116-
stats
117-
RoxygenNote: 7.2.1
117+
stats,
118+
zellkonverter
119+
RoxygenNote: 7.2.3
118120
Suggests:
119121
testthat,
120122
Rsubread,

NAMESPACE

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ export(plotSCEViolin)
111111
export(plotSCEViolinAssayData)
112112
export(plotSCEViolinColData)
113113
export(plotScDblFinderResults)
114+
export(plotScanpyDotPlot)
115+
export(plotScanpyEmbedding)
116+
export(plotScanpyHVG)
117+
export(plotScanpyHeatmap)
118+
export(plotScanpyMarkerGenes)
119+
export(plotScanpyMarkerGenesDotPlot)
120+
export(plotScanpyMarkerGenesHeatmap)
121+
export(plotScanpyMarkerGenesMatrixPlot)
122+
export(plotScanpyMarkerGenesViolin)
123+
export(plotScanpyMatrixPlot)
124+
export(plotScanpyPCA)
125+
export(plotScanpyPCAGeneRanking)
126+
export(plotScanpyPCAVariance)
127+
export(plotScanpyViolin)
114128
export(plotScdsHybridResults)
115129
export(plotScrubletResults)
116130
export(plotSeuratElbow)
@@ -182,6 +196,14 @@ export(runQuickUMAP)
182196
export(runSCANORAMA)
183197
export(runSCMerge)
184198
export(runScDblFinder)
199+
export(runScanpyFindClusters)
200+
export(runScanpyFindHVG)
201+
export(runScanpyFindMarkers)
202+
export(runScanpyNormalizeData)
203+
export(runScanpyPCA)
204+
export(runScanpyScaleData)
205+
export(runScanpyTSNE)
206+
export(runScanpyUMAP)
185207
export(runScranSNN)
186208
export(runScrublet)
187209
export(runSeuratFindClusters)
@@ -245,7 +267,7 @@ import(DelayedArray)
245267
import(DropletUtils)
246268
import(GSVAdata)
247269
import(SingleCellExperiment)
248-
import(fishpond)
270+
import(eds)
249271
importFrom(BiocParallel,SerialParam)
250272
importFrom(S4Vectors,"metadata<-")
251273
importFrom(S4Vectors,metadata)

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Changes in Version 2.8.1 (2022-03-10)
2+
================================================================================
3+
* Added scanpy wrapper functions for use from console
4+
* Added scanpy UI curated workflow
5+
* Integrated scanpy to a la carte workflow
6+
* Fixed a bug in importing fluidigm dataset
7+
* Updated downloading features in the Shiny app
8+
* Added error checking around Enrichr functions
9+
* Minor tweaks to plot defaults
10+
111
Changes in Version 2.8.0 (2022-12-19)
212
================================================================================
313
* Updated version to match Bioconductor version

R/enrichRSCE.R

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ runEnrichR <- function(inSCE,
8585
internetConnection <- suppressWarnings(Biobase::testBioCConnection())
8686
#check for internet connection
8787
if (!internetConnection){
88-
stop("Please connect to the Internet and continue..")
88+
stop("The Enrichr database could not be queried. No internet connection available.")
8989
}
9090
err <- tryCatch(
9191
{
@@ -95,38 +95,42 @@ runEnrichR <- function(inSCE,
9595
)
9696
#options(enrichR.base.address = "https://maayanlab.cloud/Enrichr/")
9797
#options(enrichR.live = TRUE)
98-
temp_db <- enrichR::listEnrichrDbs()
98+
temp_db <- NULL
99+
err <- tryCatch(
100+
{
101+
temp_db <- .getEnrichrDB(noConnect = "error")
102+
},
103+
error = function(e) {}
104+
)
99105
enrdb <- temp_db$libraryName
100106
#test for db existing
101107
if (is.null(db)){
102108
db <- enrdb
103109
} else if (!all(db %in% enrdb)){
104110
db.notFound <- db[!db %in% enrdb]
105-
stop("database ", paste(db.notFound, collapse = ", "), " do not exist.")
111+
stop("Database(s) ", paste(db.notFound, collapse = ", "), " were not found in Enrichr.")
106112
}
107113

108114
enriched <- enrichR::enrichr(features, db)
109115
enriched <- data.frame(data.table::rbindlist(enriched, use.names = TRUE,
110116
fill = TRUE,
111117
idcol = "Database_selected"))
112118

113-
enriched$link <- vapply(enriched$Database_selected, function(x){
114-
temp_db$link[temp_db$libraryName %in% x]
115-
}, FUN.VALUE = character(1))
116-
117-
#sort the results based on p-values
118-
enriched <- enriched[order(enriched$P.value, decreasing = FALSE), ]
119-
120-
#round the numeric values to their 7th digit
121-
#nums <- vapply(enriched, is.numeric, FUN.VALUE = logical(1))
122-
#enriched[, nums] <- round(enriched[, nums], digits = 7)
119+
if(!is.null(enriched) && nrow(enriched) > 0) {
120+
121+
#sort the results based on p-values
122+
enriched <- enriched[order(enriched$P.value, decreasing = FALSE), ]
123+
124+
getEnrichRResult(inSCE, analysisName) <- list(result = enriched,
125+
param = list(
126+
features = features,
127+
by = by,
128+
db = db
129+
))
130+
} else {
131+
stop("No enrichments identified. No enrichment results were created.")
132+
}
123133

124-
getEnrichRResult(inSCE, analysisName) <- list(result = enriched,
125-
param = list(
126-
features = features,
127-
by = by,
128-
db = db
129-
))
130134
return(inSCE)
131135
}
132136

@@ -181,3 +185,17 @@ setReplaceMethod("getEnrichRResult",
181185
S4Vectors::metadata(inSCE)$sctk$runEnrichR[[analysisName]] <- value
182186
return(inSCE)
183187
})
188+
189+
.getEnrichrDB <- function(noConnect = c("warn", "error", "ignore")) {
190+
db <- NULL
191+
noConnect <- match.arg(noConnect)
192+
db <- enrichR::listEnrichrDbs()
193+
if(is.null(db)) {
194+
if(noConnect == "error") {
195+
stop("Connection to the online Enrichr database could not be established. No database information retrieved.")
196+
} else if (noConnect == "warn") {
197+
warning("Connection to the online Enrichr database could not be established. No database information retrieved.")
198+
}
199+
}
200+
return(db)
201+
}

R/getTopHVG.R

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#' @param inSCE Input \linkS4class{SingleCellExperiment} object
1212
#' @param method Specify which method to use for variable gene extraction
1313
#' from Seurat \code{"vst"}, \code{"mean.var.plot"}, \code{"dispersion"} or
14-
#' Scran \code{"modelGeneVar"}. Default \code{"vst"}
14+
#' Scran \code{"modelGeneVar"} or Scanpy \code{"seurat"}, \code{"cell_ranger"},
15+
#' \code{"seurat_v3"}. Default \code{"vst"}
1516
#' @param hvgNumber Specify the number of top variable genes to extract.
1617
#' @param useFeatureSubset Get the feature names in the HVG list set by
1718
#' \code{setTopHVG}. Will ignore \code{method} and \code{hvgNumber} if not
@@ -52,7 +53,8 @@
5253
#' @importFrom S4Vectors metadata
5354
getTopHVG <- function(inSCE,
5455
method = c("vst", "dispersion",
55-
"mean.var.plot", "modelGeneVar"),
56+
"mean.var.plot", "modelGeneVar", "seurat",
57+
"seurat_v3", "cell_ranger"),
5658
hvgNumber = 2000,
5759
useFeatureSubset = NULL,
5860
featureDisplay = metadata(inSCE)$featureDisplay) {
@@ -64,7 +66,12 @@ getTopHVG <- function(inSCE,
6466
} else {
6567
metrics <- .dfFromHVGMetric(inSCE, method)
6668
metrics <- metrics[order(-metrics$v_rank),]
67-
metrics <- metrics[metrics$v_rank > 0, ]
69+
if (method == "seurat"){
70+
metrics <- metrics[metrics$v_plot > 0, ]
71+
}
72+
else{
73+
metrics <- metrics[metrics$v_rank > 0, ]
74+
}
6875
if (method == "mean.var.plot") {
6976
means.use <- (metrics$mean > 0.1) & (metrics$mean < 8)
7077
dispersions.use <- (metrics$v_plot > 1) & (metrics$v_plot < Inf)
@@ -87,7 +94,8 @@ getTopHVG <- function(inSCE,
8794
#' @importFrom S4Vectors metadata<-
8895
setTopHVG <- function(inSCE,
8996
method = c("vst", "dispersion",
90-
"mean.var.plot", "modelGeneVar"),
97+
"mean.var.plot", "modelGeneVar", "seurat",
98+
"seurat_v3", "cell_ranger"),
9199
hvgNumber = 2000,
92100
featureSubsetName = NULL,
93101
genes = NULL, genesBy = NULL,
@@ -138,13 +146,15 @@ setTopHVG <- function(inSCE,
138146
#' @param inSCE Input \linkS4class{SingleCellExperiment} object
139147
#' @param method Specify which method to use for variable gene extraction
140148
#' from Seurat \code{"vst"}, \code{"mean.var.plot"}, \code{"dispersion"} or
141-
#' Scran \code{"modelGeneVar"}. Default \code{"vst"}
149+
#' Scran \code{"modelGeneVar"} or Scanpy \code{"seurat"}, \code{"cell_ranger"},
150+
#' \code{"seurat_v3"}. Default \code{"vst"}
142151
#' @return data.frame object of HVG metrics calculated by \code{method},
143152
#' containing columns of \code{"mean"}, \code{"v_rank"}, \code{"v_plot"}
144153
#' @noRd
145154
.dfFromHVGMetric <- function(inSCE,
146155
method = c("vst", "mean.var.plot", "dispersion",
147-
"modelGeneVar")) {
156+
"modelGeneVar", "seurat",
157+
"seurat_v3", "cell_ranger")) {
148158
method <- match.arg(method)
149159
df <- data.frame(featureNames = rownames(inSCE))
150160
if (method == "vst") {
@@ -167,6 +177,39 @@ setTopHVG <- function(inSCE,
167177
"Run `runSeuratFindHVG()` with 'dispersion' method ",
168178
"before using this function!")
169179
}
180+
}else if (method == "seurat_v3") {
181+
m <- "means"
182+
v_rank <- "variances"
183+
v_plot <- "variances_norm"
184+
if (is.null(rowData(inSCE)[[v_rank]]) ||
185+
is.null(rowData(inSCE)[[m]]) ||
186+
is.null(rowData(inSCE)[[v_plot]])) {
187+
stop("Scanpy variance metric not found in inSCE. ",
188+
"Run `runScanpyFindHVG()` with 'seurat_v3' method ",
189+
"before using this function!")
190+
}
191+
}else if (method == "cell_ranger") {
192+
m <- "means"
193+
v_rank <- "dispersions"
194+
v_plot <- "dispersions_norm"
195+
if (is.null(rowData(inSCE)[[v_rank]]) ||
196+
is.null(rowData(inSCE)[[m]]) ||
197+
is.null(rowData(inSCE)[[v_plot]])) {
198+
stop("Scanpy dispersion metric not found in inSCE. ",
199+
"Run `runScanpyFindHVG()` with 'cell_ranger' method ",
200+
"before using this function!")
201+
}
202+
}else if (method == "seurat") {
203+
m <- "means"
204+
v_rank <- "dispersions"
205+
v_plot <- "dispersions_norm"
206+
if (is.null(rowData(inSCE)[[v_rank]]) ||
207+
is.null(rowData(inSCE)[[m]]) ||
208+
is.null(rowData(inSCE)[[v_plot]])) {
209+
stop("Scanpy dispersion metric not found in inSCE. ",
210+
"Run `runScanpyFindHVG()` with 'dispersion' method ",
211+
"before using this function!")
212+
}
170213
} else if (method == "modelGeneVar") {
171214
m <- "scran_modelGeneVar_mean"
172215
v_rank <- "scran_modelGeneVar_bio"

0 commit comments

Comments
 (0)