Skip to content

Commit 4b32e61

Browse files
committed
Merge branch 'release/v2.0.9' into main
2 parents 331650d + 5a71b66 commit 4b32e61

7 files changed

Lines changed: 121 additions & 25 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.8
4+
Version: 2.0.9
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.8
2+
VERSION=2.0.9
33

44
.PHONY: help
55

R/gm_report.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#' @importFrom xaringanExtra style_panelset
9292
#' @importFrom xaringanExtra style_panelset_tabs
9393
#' @importFrom BiocManager install
94+
#' @importFrom DT datatable
9495
#' @importFrom knitr opts_chunk
9596
#' @importFrom knitr asis_output
9697
#' @importFrom Seurat VlnPlot
@@ -166,9 +167,12 @@ gm_report <- function(cluster_set = NULL,
166167
"exp_stats",
167168
"exp_genes",
168169
"exp_heatmap",
169-
"exp_dimplot",
170+
"exp_pca",
171+
"exp_elbow",
172+
"exp_umap",
170173
"exp_metrics",
171174
"exp_pop",
175+
"exp_pop_table",
172176
"exp_spatial_dist",
173177
"exp_spatial_dimplot",
174178
"exp_mean_1",

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v2.0.9
4+
5+
* Various improvement for gm_report(): pca, elbow plot, table format...
6+
37
## v2.0.8
48

59
* Various fix for gm_report()

inst/rmarkdown/index.Rmd

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ knitr::opts_chunk$set(
4343
}
4444
```
4545

46+
```{r include = FALSE}
47+
# from https://tinyurl.com/mwxj7544
48+
DT::datatable(NULL)
49+
```
50+
4651
```{r, section_gen_info_1, eval="exp_info" %in% section, echo=FALSE, results = "asis"}
4752
knitr::asis_output("# All Modules ")
4853
```
@@ -132,41 +137,59 @@ if(nrow(workflow_params) > 0)
132137
knitr::asis_output("## Experiment information {.panelset}")
133138
```
134139

135-
```{r, section_gen_info_15, eval="exp_dimplot" %in% section, echo=FALSE, results = "asis"}
136-
knitr::asis_output("### Dimplot")
140+
```{r, section_gen_info_14a, eval="exp_pca" %in% section, echo=FALSE, results = "asis"}
141+
knitr::asis_output("### PCA")
137142
```
138143

139-
```{r, section_gen_info_16, eval="exp_dimplot" %in% section, echo=FALSE, results = "asis"}
140-
knitr::asis_output("A UMAP showing the cell/spot classes.")
144+
```{r, section_gen_info_14b, eval="exp_pca" %in% section, echo=FALSE, results = "asis"}
145+
knitr::asis_output("A 2D plot showing the first and second components of the PCA.")
141146
```
142147

143-
```{r section_gen_info_17, echo=FALSE, eval="exp_dimplot" %in% section, echo=FALSE, results = "asis"}
144-
identities <- grep("seurat_clusters",
145-
colnames(seurat_object@meta.data), perl=TRUE, val=TRUE)
146-
if(length(identities))
147-
Seurat::DimPlot(seurat_object)
148+
```{r section_gen_info_14c, echo=FALSE, eval="exp_pca" %in% section, echo=FALSE, results = "asis"}
149+
Seurat::DimPlot(seurat_object, reduction = "pca")
148150
```
149151

152+
```{r, section_gen_info_14d, eval="exp_elbow" %in% section, echo=FALSE, results = "asis"}
153+
knitr::asis_output("### ElbowPlot")
154+
```
150155

156+
```{r, section_gen_info_14e, eval="exp_elbow" %in% section, echo=FALSE, results = "asis"}
157+
knitr::asis_output("The *Seurat::ElbowPlot()* function is used in the context of dimensionality reduction, specifically Principal Component Analysis (PCA). It helps determine the optimal number of principal components (PCs) to use for downstream analyses like clustering, UMAP, or t-SNE. ElbowPlot helps you visualize which PCs carry meaningful biological signal versus noise.")
158+
```
159+
160+
```{r section_gen_info_14f, echo=FALSE, eval="exp_elbow" %in% section, echo=FALSE, results = "asis"}
161+
Seurat::ElbowPlot(seurat_object, reduction = "pca")
162+
```
163+
164+
```{r, section_gen_info_15, eval="exp_umap" %in% section, echo=FALSE, results = "asis"}
165+
knitr::asis_output("### Dimplot")
166+
```
167+
168+
```{r, section_gen_info_16, eval="exp_umap" %in% section, echo=FALSE, results = "asis"}
169+
knitr::asis_output("A UMAP showing the cell/spot classes.")
170+
```
171+
172+
```{r section_gen_info_17, echo=FALSE, eval="exp_umap" %in% section, echo=FALSE, results = "asis"}
173+
Seurat::DimPlot(seurat_object)
174+
```
151175

152176

153177

154178
```{r, section_gen_info_17a, eval="exp_metrics" %in% section, echo=FALSE, results = "asis"}
155179
knitr::asis_output("### QC Metrics")
156180
```
157181

158-
```{r, section_gen_info_17b, eval="exp_dimplot" %in% section, echo=FALSE, results = "asis"}
159-
knitr::asis_output("Seurat provides a convenient framework for exploring quality control (QC) metrics and filtering cells based on user-defined criteria. A commonly used QC metrics is the the number of unique genes detected per cell. Low-quality cells or empty droplets typically show very few genes, while doublets or multiplets may display abnormally high gene counts (but also proliferating cells !!). Another key metric is the total number of molecules detected per cell, which strongly correlates with the number of unique genes. The proportion of reads mapping to the mitochondrial genome is also often used, as low-quality or dying cells tend to exhibit elevated mitochondrial content. To compute this, Seurat’s PercentageFeatureSet() function can be used to calculate the percentage of counts originating from a specified set of features, typically using all genes that begin with 'MT-' (or 'mt-') to represent mitochondrial genes. An interesting control is also provided by ribosomal protein genes that are expected to be expressed in all cells. The percentage of counts from ribosomal genes can be calculated similarly to mitochondrial genes, using the pattern '^[Rr][Pp][LlSs]'. These QC metrics can be visualized using the VlnPlot() function, which generates violin plots for each metric, allowing for easy comparison across cell populations.")
182+
```{r, section_gen_info_17b, eval="exp_metrics" %in% section, echo=FALSE, results = "asis"}
183+
knitr::asis_output("Seurat provides a convenient framework for exploring quality control (QC) metrics and filtering cells based on user-defined criteria. A commonly used QC metrics is the the number of unique genes detected per cell. Low-quality cells or empty droplets typically show very few genes, while doublets or multiplets may display abnormally high gene counts (but also proliferating cells !!). Another key metric is the total number of molecules detected per cell, which strongly correlates with the number of unique genes. The proportion of reads mapping to the mitochondrial genome is also often used, as low-quality or dying cells tend to exhibit elevated mitochondrial content. To compute this, Seurat’s PercentageFeatureSet() function can be used to calculate the percentage of counts originating from a specified set of features, typically using all genes that begin with 'MT-' (or 'mt-') to represent mitochondrial genes. An interesting control is also provided by ribosomal protein genes that are expected to be expressed in all cells. The percentage of counts from ribosomal genes can be calculated similarly to mitochondrial genes, using the pattern '[Rr][Pp][LlSs][0-9]+'. These QC metrics can be visualized using the VlnPlot() function, which generates violin plots for each metric, allowing for easy comparison across cell populations.")
160184
```
161185

162186
```{r section_gen_info_17c, echo=FALSE, eval="exp_metrics" %in% section, echo=FALSE, results = "asis"}
163-
seurat_object[["percent.mt"]] <- PercentageFeatureSet(seurat_object, pattern = "^[Mm][Tt]-")
164-
seurat_object[["percent.ribo"]] <- PercentageFeatureSet(seurat_object, pattern = "^[Rr][Pp][Ll]")
165-
var_qc <- grep("(^nFeature)|(nCount)|(percent.mt)(percent.ribo)", colnames(seurat_object@meta.data), perl = TRUE, value = TRUE)
187+
seurat_object[["percent.mt"]] <- Seurat::PercentageFeatureSet(seurat_object, pattern = "^[Mm][Tt]-")
188+
seurat_object[["percent.ribo"]] <- Seurat::PercentageFeatureSet(seurat_object, pattern = "^[Rr][Pp][LlSs][0-9]+")
189+
var_qc <- grep("(^nFeature)|(nCount)|(percent.mt)|(percent.ribo)", colnames(seurat_object@meta.data), perl = TRUE, value = TRUE)
166190
for(qc in var_qc){
167-
VlnPlot(seurat_object, features = qc, ncol = 1)
191+
print(Seurat::VlnPlot(seurat_object, features = qc, ncol = 1))
168192
}
169-
170193
```
171194

172195
```{r, section_gen_info_17d, eval="exp_pop" %in% section, echo=FALSE, results = "asis"}
@@ -190,6 +213,30 @@ ggplot2::ggplot(df, mapping = ggplot2::aes(x=Cell_Identity, y=Count, fill=Cell_I
190213
ggplot2::theme(legend.position = "none")
191214
```
192215

216+
```{r, section_gen_info_17d, eval="exp_pop_table" %in% section, echo=FALSE, results = "asis"}
217+
knitr::asis_output("### Population table")
218+
```
219+
220+
```{r, section_gen_info_17e, eval="exp_pop_table" %in% section, echo=FALSE, results = "asis"}
221+
knitr::asis_output("The size of each cell population as a table.")
222+
```
223+
224+
```{r section_gen_info_17f, echo=FALSE, eval="exp_pop_table" %in% section, echo=FALSE, results = "asis"}
225+
df <- as.data.frame(table(Seurat::Idents(seurat_object)))
226+
colnames(df) <- c("Cell_Identity", "Count")
227+
df$Cell_Identity <- factor(df$Cell_Identity, levels=df$Cell_Identity[order(df$Count, decreasing = FALSE)])
228+
DT::datatable(
229+
df,
230+
extensions = 'Buttons',
231+
options = list(
232+
dom = 'Bfrtip',
233+
buttons =
234+
list(list(
235+
extend = 'csv',
236+
title = "cell_population_size"))))
237+
```
238+
239+
193240
```{r, section_gen_info_18, eval="exp_spatial_dist" %in% section, echo=FALSE, results = "asis"}
194241
knitr::asis_output("### Spatial distribution")
195242
```
@@ -293,7 +340,15 @@ df <- data.frame(Module=setNames(scigenex::gene_cluster(cluster_set), NULL),
293340
```
294341

295342
```{r section_gen_info_32_table, echo=FALSE, eval="exp_info" %in% section}
296-
DT::datatable(df)
343+
DT::datatable(
344+
df,
345+
extensions = 'Buttons',
346+
options = list(
347+
dom = 'Bfrtip',
348+
buttons =
349+
list(list(
350+
extend = 'csv',
351+
title = "gene_list_MOD_MODULE_NUMBER"))))
297352
```
298353

299354
```{r, section_gen_info_33, eval="exp_heatmap" %in% section, echo=FALSE, results = "asis"}

inst/rmarkdown/module.Rmd

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ knitr::opts_chunk$set(
3838
knitr::asis_output("# Module MODULE_NUMBER ")
3939
```
4040

41+
```{r, level_0b_MOD_MODULE_NUMBER, eval=TRUE, echo=FALSE, results = "asis"}
42+
knitr::asis_output(paste0("Module name: ", names(cluster_set[MODULE_NUMBER, ]@gene_clusters)))
43+
```
44+
4145
```{r, level_1_MOD_MODULE_NUMBER, eval=TRUE, echo=FALSE, results = "asis"}
4246
knitr::asis_output("## Expression {.panelset}")
4347
```
@@ -156,7 +160,15 @@ df <- data.frame(Module=setNames(scigenex::gene_cluster(cluster_set[MODULE_NUMBE
156160
```
157161

158162
```{r gene_info_4_MOD_MODULE_NUMBER, echo=FALSE, eval="module_genes" %in% section}
159-
DT::datatable(df)
163+
DT::datatable(
164+
df,
165+
extensions = 'Buttons',
166+
options = list(
167+
dom = 'Bfrtip',
168+
buttons =
169+
list(list(
170+
extend = 'csv',
171+
title = "gene_list_MOD_MODULE_NUMBER"))))
160172
```
161173

162174
```{r, level_2_MOD_MODULE_NUMBER, eval=TRUE, echo=FALSE, results = "asis"}
@@ -199,7 +211,6 @@ cat("\n\n")
199211
```
200212

201213

202-
203214
```{r, func_anno_MOD_MODULE_NUMBER, eval=TRUE, echo=FALSE, results = "asis"}
204215
205216
for(ann in annotation_src){
@@ -376,13 +387,16 @@ for(ann in annotation_src){
376387
377388
378389
# from https://tinyurl.com/mwxj7544
379-
print(htmltools::tagList(DT::datatable(df_edo,
390+
print(htmltools::tagList(DT::datatable(df_edo,
380391
options=list(
381-
initComplete = htmlwidgets::JS(
392+
initComplete = htmlwidgets::JS(
382393
"function(settings, json) {",
383394
paste0("$(this.api().table().container()).css({'font-size': '",
384395
font.size, "'});"),
385-
"}")
396+
"}"),
397+
dom = 'Bfrtip',
398+
buttons = list(list(extend = 'csv',
399+
title = "gene_list_MOD_MODULE_NUMBER"))
386400
))))
387401
388402
}else{

vignettes/report.Rmd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ suppressMessages(suppressWarnings(library(org.Hs.eg.db, quietly = TRUE)))
6565
library(scigenex)
6666
library(Seurat)
6767
library(org.Hs.eg.db)
68+
69+
# Create a temporary directory for the report output
70+
tmp_dir <- tempdir()
71+
72+
# Load example gene module clusters and Seurat object for spatial data
73+
load_example_dataset("7870305/files/lymph_node_tiny_clusters_2")
74+
load_example_dataset("7870305/files/lymph_node_tiny_2")
75+
76+
# Run gm_report() for spatial transcriptomics data
77+
gm_report(
78+
cluster_set = lymph_node_tiny_clusters_2[1:2,],
79+
seurat_object = lymph_node_tiny_2,
80+
annotation_src = "CC",
81+
bioc_org_db = "org.Hs.eg.db",
82+
is_spatial_exp = TRUE,
83+
SpatialFeaturePlot_params = list(pt.size.factor = 3000),
84+
SpatialDimPlot_params = list(pt.size.factor = 3000),
85+
out_dir = file.path(tmp_dir, "spatial_report")
86+
)
6887
```
6988

7089
## Some examples

0 commit comments

Comments
 (0)