Skip to content

Commit e14beb9

Browse files
committed
Merge branch 'release/v2.1.0' into main
2 parents c6f4c42 + c073546 commit e14beb9

6 files changed

Lines changed: 133 additions & 121 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: scigenex
22
Type: Package
33
Title: The scigenex package (Single-Cell Informative GENe Explorer)
4-
Version: 2.0.14
4+
Version: 2.1.0
55
Date: 2020-07-22
66
Author: J. Bavais, Sebastien Nin, Lionel Spinelli and Denis Puthier
77
Maintainer: J. Bavais <julie.bavais@yahoo.fr>

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MAKEFILE=Makefile
2-
VERSION=2.0.14
2+
VERSION=2.1.0
33

44
.PHONY: help
55

R/gm_report.R

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#' Reduce this number if you have a large dataset (e.g. > 10000 cells/spots). Otherwise the dataset will be too large to be handled by the web browser.
4242
#' @param plot_heatmap_params Some parameters for plot_heatmap() function.
4343
#' @param cnetplot_params Some parameters for enrichplot:::cnetplot.enrichResult() function.
44+
#' @param vlnPlot_params The parameters for Seurat::VlnPlot().
4445
#' @param rm_tmpdir Whether to delete temporary directory.
4546
#' @param section Which section to activate/deactivate.
4647
#' @param quiet Whether to run bookdown::render_book() quietly.
@@ -73,8 +74,8 @@
7374
#' bioc_org_db="org.Hs.eg.db",
7475
#' api_key=NULL,
7576
#' is_spatial_exp=TRUE,
76-
#' SpatialFeaturePlot_params=list(pt.size.factor = 3000),
77-
#' SpatialDimPlot_params=list(pt.size.factor = 3000)) # Object was created with an older seurat version
77+
#' SpatialFeaturePlot_params=list(pt.size.factor = 3000), # adapt the point size as
78+
#' SpatialDimPlot_params=list(pt.size.factor = 3000)) # the object was created with an older seurat version
7879
#' set_verbosity(3)
7980
#' markers <- Seurat::FindAllMarkers(lymph_node_tiny_2, only.pos = TRUE)
8081
#' cs <- cluster_set_from_seurat(lymph_node_tiny_2, markers, p_val_adj=0.001, assay="Spatial")
@@ -89,7 +90,9 @@
8990
#' sample_gg_heatmap=TRUE,
9091
#' subsample_by_ident_params=list(nbcell=20),
9192
#' bioc_org_db="org.Hs.eg.db",
92-
#' api_key=NULL) # Object was created with an older seurat version
93+
#' SpatialFeaturePlot_params=list(pt.size.factor = 3000), # adapt the point size as
94+
#' SpatialDimPlot_params=list(pt.size.factor = 3000), # the object was created with an older seurat version
95+
#' api_key=NULL)
9396
#' @importFrom fs path_home
9497
#' @importFrom bookdown render_book
9598
#' @importFrom xaringanExtra use_panelset
@@ -151,7 +154,11 @@ gm_report <- function(cluster_set = NULL,
151154
plot_profiles_params=list(to_lin=TRUE, averaged = TRUE),
152155
plot_multi_profiles_params=list(legend_name="Gene\nModule",
153156
center=FALSE),
154-
FeaturePlot_params=list(cols=RColorBrewer::brewer.pal(3, "BuPu")),
157+
FeaturePlot_params=list(cols=RColorBrewer::brewer.pal(3, "BuPu"),
158+
label = TRUE,
159+
label.size = 4,
160+
repel = TRUE,
161+
split.by = "orig.ident"),
155162
SpatialFeaturePlot_params=list(pt.size.factor = 1.7),
156163
SpatialDimPlot_params=list(pt.size.factor = 1.7),
157164
DimPlot_params=list(label = TRUE,
@@ -172,6 +179,7 @@ gm_report <- function(cluster_set = NULL,
172179
showCategory = 6,
173180
cex.params = list(category_label = 0.6,
174181
gene_label = 0.7)),
182+
vlnPlot_params=list(split.by = "orig.ident"),
175183
rm_tmpdir = TRUE,
176184
section=c("exp_info",
177185
"exp_metadata",
@@ -197,7 +205,9 @@ gm_report <- function(cluster_set = NULL,
197205
"module_heatmap",
198206
"module_iheatmap",
199207
"module_umap",
208+
"module_umap_by_ori",
200209
"module_violin",
210+
"module_violin_by_ori",
201211
"module_genes",
202212
"module_cell_annot_IA",
203213
"module_term_network",
@@ -264,11 +274,18 @@ gm_report <- function(cluster_set = NULL,
264274

265275
print_msg("Computing module scores...", msg_type = "INFO")
266276
add_module_score_used_params <- as.list(formals(Seurat:::AddModuleScore.Seurat))
277+
for(i in names(add_module_score_used_params)){
278+
if(is.null(add_module_score_used_params[[i]]) || as.character(add_module_score_used_params[[i]])[1] == "deprecated"){
279+
add_module_score_used_params <- add_module_score_used_params[names(add_module_score_used_params) != i]
280+
}
281+
}
267282

268283
for(i in names(add_module_score_params)){
269284
add_module_score_used_params[[i]] <- add_module_score_params[[i]]
270285
}
271286

287+
print_msg("Calling AddModuleScore()...", msg_type = "DEBUG")
288+
272289
add_module_score_used_params$object <- seurat_object
273290
add_module_score_used_params$features <- lapply(cluster_set@gene_clusters, gsub, pattern = "~[0-9]+$", replacement = "_")
274291
add_module_score_used_params$name <- "MOD_"

inst/rmarkdown/index.Rmd

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ DT::datatable(NULL)
5050
```
5151

5252
```{r, section_gen_info_1, eval="exp_info" %in% section, echo=FALSE, results = "asis"}
53-
knitr::asis_output("# All Modules ")
53+
knitr::asis_output("# General information")
5454
```
5555

5656
```{r, section_gen_info_2, eval="exp_info" %in% section, echo=FALSE, results = "asis"}
@@ -135,7 +135,7 @@ if(nrow(workflow_params) > 0)
135135

136136

137137
```{r, section_gen_info_14, eval=TRUE, echo=FALSE, results = "asis"}
138-
knitr::asis_output("## Experiment information {.panelset}")
138+
knitr::asis_output("## Cell/spot populations {.panelset}")
139139
```
140140

141141
```{r, section_gen_info_14a, eval="exp_pca" %in% section, echo=FALSE, results = "asis"}
@@ -172,6 +172,12 @@ knitr::asis_output("A UMAP showing the cell/spot classes.")
172172

173173
```{r section_gen_info_17, echo=FALSE, eval="exp_umap" %in% section, echo=FALSE, results = "asis"}
174174
DimPlot_used_params <- as.list(formals(Seurat::DimPlot))
175+
for(i in names(DimPlot_used_params)){
176+
if(is.null(DimPlot_used_params[[i]]) || as.character(DimPlot_used_params[[i]])[1] == "deprecated"){
177+
DimPlot_used_params <- DimPlot_used_params[names(DimPlot_used_params) != i]
178+
}
179+
}
180+
175181
for(i in names(DimPlot_params)){
176182
DimPlot_used_params[[i]] <- DimPlot_params[[i]]}
177183
DimPlot_used_params$object <- seurat_object
@@ -191,6 +197,12 @@ knitr::asis_output("A UMAP showing the cell/spot classes according to origin.")
191197

192198
```{r section_gen_info_17_1, echo=FALSE, eval="exp_umap" %in% section, echo=FALSE, results = "asis"}
193199
DimPlot_used_params <- as.list(formals(Seurat::DimPlot))
200+
for(i in names(DimPlot_used_params)){
201+
if(is.null(DimPlot_used_params[[i]]) || as.character(DimPlot_used_params[[i]])[1] == "deprecated"){
202+
DimPlot_used_params <- DimPlot_used_params[names(DimPlot_used_params) != i]
203+
}
204+
}
205+
194206
for(i in names(DimPlot_params)){
195207
DimPlot_used_params[[i]] <- DimPlot_params[[i]]}
196208
DimPlot_used_params$object <- seurat_object
@@ -293,12 +305,13 @@ colnames(df) <- c("Origin", "Cell_Identity")
293305
df$Origin <- factor(df$Origin)
294306
df$Cell_Identity <- factor(df$Cell_Identity)
295307
Cell_Identity <- Origin <- Count <- NULL
296-
ggplot2::ggplot(df, mapping = ggplot2::aes(x=Cell_Identity, fill=Origin)) +
308+
ggplot2::ggplot(df, mapping = ggplot2::aes(x=Cell_Identity, fill=Origin, by = Cell_Identity)) +
297309
ggplot2::geom_bar(position="fill") +
298-
ggplot2::labs(x="Cell Identity", y="Count") +
310+
ggplot2::labs(x="Cell Identity", y="Fraction") +
299311
ggplot2::theme_minimal() +
300312
ggplot2::coord_flip() +
301-
ggplot2::theme(legend.position = "none")
313+
ggplot2::theme(legend.position = "none") +
314+
ggplot2::geom_text(stat = ggstats::StatProp, position = ggplot2::position_fill(.5), size=2)
302315
303316
df <- as.data.frame(cbind(seurat_object@meta.data$orig.ident, Idents(seurat_object)))
304317
colnames(df) <- c("Origin", "Cell_Identity")
@@ -307,24 +320,23 @@ df$Cell_Identity <- factor(df$Cell_Identity)
307320
Cell_Identity <- Origin <- Count <- NULL
308321
ggplot2::ggplot(df, mapping = ggplot2::aes(x=Origin, fill=Cell_Identity, by = Origin)) +
309322
ggplot2::geom_bar(position="fill") +
310-
ggplot2::labs(x="fill", y="Cell_Identity") +
323+
ggplot2::labs(x="Origin", y="Cell_Identity") +
311324
ggplot2::theme_minimal() +
312325
ggplot2::geom_text(stat = ggstats::StatProp, position = ggplot2::position_fill(.5), size=2)
313326
```
314327

315328

316329

317-
```{r, section_gen_info_17d_1, eval="exp_pop_table_by_ori" %in% section, echo=FALSE, results = "asis"}
330+
```{r, section_gen_info_17d_2, eval="exp_pop_table_by_ori" %in% section, echo=FALSE, results = "asis"}
318331
knitr::asis_output("### Population table by origin")
319332
```
320333

321-
```{r, section_gen_info_17e_1, eval="exp_pop_table_by_ori" %in% section, echo=FALSE, results = "asis"}
334+
```{r, section_gen_info_17e_2, eval="exp_pop_table_by_ori" %in% section, echo=FALSE, results = "asis"}
322335
knitr::asis_output("The size of each cell population according to the corresponding sample/origin. Raw counts")
323336
```
324337

325-
```{r section_gen_info_17f_1, echo=FALSE, eval="exp_pop_table_by_ori" %in% section, echo=FALSE, results = "asis"}
326-
df <- as.data.frame(cbind(seurat_object@meta.data$orig.ident, Idents(seurat_object)))
327-
colnames(df) <- c("Origin", "Cell_Identity")
338+
```{r section_gen_info_17f_2, echo=FALSE, eval="exp_pop_table_by_ori" %in% section, echo=FALSE, results = "asis"}
339+
df <- data.frame(Origin=seurat_object@meta.data$orig.ident, Cell_Identity=Idents(seurat_object))
328340
df <- table(df$Cell_Identity, df$Origin)
329341
DT::datatable(
330342
df,
@@ -339,9 +351,6 @@ DT::datatable(
339351

340352

341353

342-
343-
344-
345354
```{r, section_gen_info_18, eval="exp_spatial_dist" %in% section, echo=FALSE, results = "asis"}
346355
knitr::asis_output("### Spatial distribution")
347356
```
@@ -351,11 +360,8 @@ knitr::asis_output("The spatial distribution of counts and features.")
351360
```
352361

353362
```{r section_gen_info_20, echo=FALSE, eval="exp_spatial_dist" %in% section, echo=FALSE, results = "asis"}
354-
SpatialFeaturePlot_used_params <- as.list(formals(Seurat::SpatialFeaturePlot))
355-
for(i in names(SpatialFeaturePlot_params)){
356-
SpatialFeaturePlot_used_params[[i]] <- SpatialFeaturePlot_params[[i]]}
357363
358-
SpatialFeaturePlot_used_params$object <- seurat_object
364+
SpatialFeaturePlot_params$object <- seurat_object
359365
360366
if(length(grep("^[Mm][Tt]-", rownames(seurat_object))) > 0 )
361367
seurat_object[["pctMito"]] <- PercentageFeatureSet(seurat_object, pattern = "^[Mm][Tt]-")
@@ -366,8 +372,8 @@ if(length(grep("^[Rr][Pp][Ll]", rownames(seurat_object))) > 0)
366372
var_qc <- grep("(^nFeature)|(^nCount)|(^pctMito)|(^pctRibo)", colnames(seurat_object@meta.data), perl = TRUE, value = TRUE)
367373
368374
for(feat in var_qc){
369-
SpatialFeaturePlot_used_params$features <- feat
370-
tryerror <- try(base::do.call(Seurat::SpatialFeaturePlot, SpatialFeaturePlot_used_params)) # got some Error in `FetchData()`...
375+
SpatialFeaturePlot_params$features <- feat
376+
tryerror <- try(base::do.call(Seurat::SpatialFeaturePlot, SpatialFeaturePlot_params)) # got some Error in `FetchData()`...
371377
if(!inherits(tryerror, "try-error")){
372378
print(tryerror)
373379
}
@@ -387,15 +393,10 @@ identities <- grep("seurat_clusters",
387393
colnames(seurat_object@meta.data), perl=TRUE, val=TRUE)
388394
389395
if(length(identities)){
390-
SpatialDimPlot_used_params <- as.list(formals(Seurat::SpatialDimPlot))
391-
392-
for(i in names(SpatialDimPlot_params)){
393-
SpatialDimPlot_used_params[[i]] <- SpatialDimPlot_params[[i]]
394-
}
395396
396-
SpatialDimPlot_used_params$object <- seurat_object
397+
SpatialDimPlot_params$object <- seurat_object
397398
398-
print(base::do.call(Seurat::SpatialDimPlot, SpatialDimPlot_used_params))
399+
print(base::do.call(Seurat::SpatialDimPlot, SpatialDimPlot_params))
399400
400401
}
401402
@@ -433,7 +434,6 @@ knitr::asis_output("### Module genes")
433434
```
434435

435436

436-
437437
```{r, section_gen_info_30, eval="exp_genes" %in% section, echo=FALSE, results = "asis"}
438438
knitr::asis_output("This section provides information about gene contained in modules.")
439439
```
@@ -497,14 +497,10 @@ knitr::asis_output("Mean expression of gene across cell/spot populations for eac
497497

498498
```{r section_gen_info_38, echo=FALSE, eval="exp_mean_1" %in% section}
499499
500-
plot_multi_profiles_used_params <- as.list(formals(plot_multi_profiles))
501-
for(i in names(plot_multi_profiles_params))
502-
plot_multi_profiles_used_params[[i]] <- plot_multi_profiles_params[[i]]
500+
plot_multi_profiles_params$data <- cluster_set
501+
plot_multi_profiles_params$ident <- Idents(seurat_object)
503502
504-
plot_multi_profiles_used_params$data <- cluster_set
505-
plot_multi_profiles_used_params$ident <- Idents(seurat_object)
506-
507-
print(base::do.call(plot_multi_profiles, plot_multi_profiles_used_params))
503+
print(base::do.call(plot_multi_profiles, plot_multi_profiles_params))
508504
```
509505

510506
```{r, section_gen_info_39, eval="exp_mean_2" %in% section, echo=FALSE, results = "asis"}
@@ -516,10 +512,8 @@ knitr::asis_output("Mean expression of gene across cell/spot populations for eac
516512
```
517513

518514
```{r section_gen_info_41, echo=FALSE, eval="exp_mean_2" %in% section}
519-
plot_profiles_used_params <- as.list(formals(plot_profiles))
520-
for(i in names(plot_profiles_params))
521-
plot_profiles_used_params[[i]] <- plot_profiles_params[[i]]
522-
plot_profiles_used_params$data <- cluster_set
523-
plot_profiles_used_params$ident <- Idents(seurat_object)
524-
print(base::do.call(plot_profiles, plot_profiles_used_params))
515+
516+
plot_profiles_params$data <- cluster_set
517+
plot_profiles_params$ident <- Idents(seurat_object)
518+
print(base::do.call(plot_profiles, plot_profiles_params))
525519
```

0 commit comments

Comments
 (0)