Skip to content

Commit 4c43d87

Browse files
authored
Merge pull request #203 from samuel-marsh/release/3.0.0
Release/3.0.0
2 parents fc7a282 + 90247e9 commit 4c43d87

File tree

533 files changed

+24451
-10301
lines changed

Some content is hidden

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

533 files changed

+24451
-10301
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ vignettes/*.orig$
1515
^README\.Rmd$
1616
^cran-comments\.md$
1717
^CRAN-SUBMISSION$
18+
^data-raw$

CRAN-SUBMISSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 2.1.2
2-
Date: 2024-02-27 15:16:14 UTC
3-
SHA: 3789733c4393d9d0abdff14c94b57f25a4da29ff
1+
Version: 3.0.0
2+
Date: 2024-12-05 20:08:02 UTC
3+
SHA: 0193fbdf787f715d4eb9e36b96bb74d32fc9ad15

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Package: scCustomize
22
Type: Package
33
Title: Custom Visualizations & Functions for Streamlined Analyses of Single Cell Sequencing
44
Description: Collection of functions created and/or curated to aid in the visualization and analysis of single-cell data using 'R'. 'scCustomize' aims to provide 1) Customized visualizations for aid in ease of use and to create more aesthetic and functional visuals. 2) Improve speed/reproducibility of common tasks/pieces of code in scRNA-seq analysis with a single or group of functions. For citation please use: Marsh SE (2021) "Custom Visualizations & Functions for Streamlined Analyses of Single Cell Sequencing" <doi:10.5281/zenodo.5706430> RRID:SCR_024675.
5-
Version: 2.1.2
6-
Date: 2024-02-27
5+
Version: 3.0.0
6+
Date: 2024-12-05
77
Authors@R: c(
88
person(given = "Samuel", family = "Marsh", email = "samuel.marsh@childrens.harvard.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3012-6945")),
99
person(given = "Ming", family = "Tang", role = c("ctb"), email = "tangming2005@gmail.com"),
@@ -68,4 +68,4 @@ License: GPL (>= 3)
6868
Encoding: UTF-8
6969
LazyData: true
7070
Roxygen: list(markdown = TRUE)
71-
RoxygenNote: 7.3.1
71+
RoxygenNote: 7.3.2

NAMESPACE

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method("Idents<-",liger)
34
S3method(Add_Cell_Complexity,Seurat)
45
S3method(Add_Cell_Complexity,liger)
6+
S3method(Add_Cell_QC_Metrics,Seurat)
7+
S3method(Add_Cell_QC_Metrics,liger)
8+
S3method(Add_Hemo,Seurat)
9+
S3method(Add_Hemo,liger)
510
S3method(Add_Mito_Ribo,Seurat)
611
S3method(Add_Mito_Ribo,liger)
12+
S3method(Add_Top_Gene_Pct,Seurat)
13+
S3method(Add_Top_Gene_Pct,liger)
14+
S3method(Cells,liger)
15+
S3method(Embeddings,liger)
16+
S3method(Features,liger)
717
S3method(Fetch_Meta,Seurat)
818
S3method(Fetch_Meta,liger)
19+
S3method(Idents,liger)
20+
S3method(Rename_Clusters,Seurat)
21+
S3method(Rename_Clusters,liger)
22+
S3method(WhichCells,liger)
923
S3method(as.LIGER,Seurat)
1024
S3method(as.LIGER,list)
1125
S3method(as.Seurat,liger)
1226
S3method(as.anndata,Seurat)
1327
S3method(as.anndata,liger)
28+
export("Idents<-")
1429
export(Add_Alt_Feature_ID)
1530
export(Add_CellBender_Diff)
1631
export(Add_Cell_Complexity)
1732
export(Add_Cell_Complexity_LIGER)
1833
export(Add_Cell_Complexity_Seurat)
1934
export(Add_Cell_QC_Metrics)
35+
export(Add_Hemo)
2036
export(Add_Mito_Ribo)
2137
export(Add_Mito_Ribo_LIGER)
2238
export(Add_Mito_Ribo_Seurat)
2339
export(Add_Pct_Diff)
2440
export(Add_Sample_Meta)
41+
export(Add_Top_Gene_Pct)
2542
export(Add_Top_Gene_Pct_Seurat)
2643
export(Barcode_Plot)
2744
export(Blank_Theme)
2845
export(Case_Check)
2946
export(CellBender_Diff_Plot)
3047
export(CellBender_Feature_Diff)
3148
export(Cell_Highlight_Plot)
49+
export(Cells)
50+
export(Cells_by_Identities_LIGER)
51+
export(Cells_per_Sample)
3252
export(Change_Delim_All)
3353
export(Change_Delim_Prefix)
3454
export(Change_Delim_Suffix)
@@ -49,16 +69,21 @@ export(DimPlot_LIGER)
4969
export(DimPlot_scCustom)
5070
export(DiscretePalette_scCustomize)
5171
export(DotPlot_scCustom)
72+
export(Embeddings)
5273
export(Extract_Modality)
5374
export(Extract_Sample_Meta)
5475
export(Extract_Top_Markers)
76+
export(Factor_Cor_Plot)
5577
export(FeaturePlot_DualAssay)
5678
export(FeaturePlot_scCustom)
5779
export(FeatureScatter_scCustom)
5880
export(Feature_Present)
81+
export(Features)
5982
export(Fetch_Meta)
83+
export(Find_Factor_Cor)
6084
export(Gene_Present)
6185
export(Hue_Pal)
86+
export(Idents)
6287
export(Iterate_Barcode_Rank_Plot)
6388
export(Iterate_Cluster_Highlight_Plot)
6489
export(Iterate_DimPlot_bySample)
@@ -69,7 +94,6 @@ export(Iterate_Plot_Density_Custom)
6994
export(Iterate_Plot_Density_Joint)
7095
export(Iterate_VlnPlot_scCustom)
7196
export(JCO_Four)
72-
export(LIGER_Features)
7397
export(Liger_to_Seurat)
7498
export(MAD_Stats)
7599
export(Median_Stats)
@@ -93,6 +117,7 @@ export(Plot_Median_Genes)
93117
export(Plot_Median_Mito)
94118
export(Plot_Median_Other)
95119
export(Plot_Median_UMIs)
120+
export(Proportion_Plot)
96121
export(Pull_Cluster_Annotation)
97122
export(Pull_Directory_List)
98123
export(QC_Histogram)
@@ -105,6 +130,7 @@ export(QC_Plots_Feature)
105130
export(QC_Plots_Genes)
106131
export(QC_Plots_Mito)
107132
export(QC_Plots_UMIs)
133+
export(Random_Cells_Downsample)
108134
export(Read10X_GEO)
109135
export(Read10X_Multi_Directory)
110136
export(Read10X_h5_GEO)
@@ -114,6 +140,7 @@ export(Read_CellBender_h5_Multi_Directory)
114140
export(Read_CellBender_h5_Multi_File)
115141
export(Read_GEO_Delim)
116142
export(Read_Metrics_10X)
143+
export(Read_Metrics_CellBender)
117144
export(Reduction_Loading_Present)
118145
export(Rename_Clusters)
119146
export(Replace_Suffix)
@@ -134,23 +161,28 @@ export(Seq_QC_Plot_Transcriptome)
134161
export(Seq_QC_Plot_UMIs)
135162
export(Setup_scRNAseq_Project)
136163
export(Single_Color_Palette)
164+
export(SpatialDimPlot_scCustom)
137165
export(Split_FeatureScatter)
138166
export(Split_Layers)
139167
export(Split_Vector)
140168
export(Stacked_VlnPlot)
141169
export(Store_Misc_Info_Seurat)
142170
export(Store_Palette_Seurat)
171+
export(Subset_LIGER)
143172
export(Top_Genes_Factor)
144173
export(UnRotate_X)
145174
export(Updated_HGNC_Symbols)
175+
export(Updated_MGI_Symbols)
146176
export(VariableFeaturePlot_scCustom)
147177
export(Variable_Features_ALL_LIGER)
148178
export(VlnPlot_scCustom)
179+
export(WhichCells)
149180
export(as.LIGER)
150181
export(as.Seurat)
151182
export(as.anndata)
152183
export(plotFactors_scCustom)
153184
export(scCustomize_Palette)
185+
export(seq_zeros)
154186
export(theme_ggprism_mod)
155187
export(viridis_dark_high)
156188
export(viridis_inferno_dark_high)
@@ -182,11 +214,16 @@ importFrom(Seurat,Read10X_h5)
182214
importFrom(Seurat,VariableFeaturePlot)
183215
importFrom(Seurat,VizDimLoadings)
184216
importFrom(Seurat,VlnPlot)
217+
importFrom(SeuratObject,"Idents<-")
218+
importFrom(SeuratObject,Cells)
185219
importFrom(SeuratObject,DefaultDimReduc)
220+
importFrom(SeuratObject,Embeddings)
186221
importFrom(SeuratObject,Features)
222+
importFrom(SeuratObject,Idents)
187223
importFrom(SeuratObject,JoinLayers)
188224
importFrom(SeuratObject,LayerData)
189225
importFrom(SeuratObject,Layers)
226+
importFrom(SeuratObject,WhichCells)
190227
importFrom(SeuratObject,as.Seurat)
191228
importFrom(circlize,colorRamp2)
192229
importFrom(cowplot,theme_cowplot)
@@ -208,6 +245,7 @@ importFrom(dplyr,mutate)
208245
importFrom(dplyr,n)
209246
importFrom(dplyr,pull)
210247
importFrom(dplyr,rename)
248+
importFrom(dplyr,right_join)
211249
importFrom(dplyr,select)
212250
importFrom(dplyr,setdiff)
213251
importFrom(dplyr,slice)
@@ -216,6 +254,7 @@ importFrom(dplyr,summarise)
216254
importFrom(dplyr,summarize)
217255
importFrom(dplyr,union)
218256
importFrom(forcats,fct_relevel)
257+
importFrom(forcats,fct_rev)
219258
importFrom(ggbeeswarm,geom_quasirandom)
220259
importFrom(ggplot2,theme)
221260
importFrom(ggprism,theme_prism)
@@ -258,8 +297,11 @@ importFrom(scales,alpha)
258297
importFrom(scales,hue_pal)
259298
importFrom(scales,label_percent)
260299
importFrom(scattermore,geom_scattermore)
300+
importFrom(stats,as.dist)
261301
importFrom(stats,complete.cases)
262302
importFrom(stats,cor)
303+
importFrom(stats,cutree)
304+
importFrom(stats,hclust)
263305
importFrom(stats,kmeans)
264306
importFrom(stats,mad)
265307
importFrom(stats,median)
@@ -271,6 +313,7 @@ importFrom(stringi,stri_replace_last_fixed)
271313
importFrom(stringr,str_c)
272314
importFrom(stringr,str_detect)
273315
importFrom(stringr,str_extract)
316+
importFrom(stringr,str_pad)
274317
importFrom(stringr,str_replace)
275318
importFrom(stringr,str_replace_na)
276319
importFrom(stringr,str_to_lower)

NEWS.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,115 @@
1+
# scCustomize 3.0.0 (2024-12-05)
2+
## Added
3+
**Major Updates to Functionality with rliger Package:**
4+
*Added new utility functions to interact with liger v2.0.0+ object format change:*
5+
- `Subset_LIGER` to quickly subset by cluster or other meta data variable.
6+
- `Cells_by_Identities_LIGER` to extract list of barcodes sorted by values within given meta data column.
7+
8+
*Extended the following Seurat/SeuratObject generic functions to work seamlessly with liger objects:*
9+
- `Cells` to extract vector of all cells or list vectors of cells by dataset.
10+
- `Features` to extract vector of all features or list vectors of features by dataset.
11+
- `WhichCells` to extract vector or list of cells matching identity criteria.
12+
- `Embeddings` to extract matrix containing dimensionality reduction embeddings or iNMF h.norm matrix.
13+
- `Idents` and `Idents<-` to extract and set default identities/clusters.
14+
15+
*Updated functions to interact with both old and new style liger objects:*
16+
- `plotFactors_scCustom()`
17+
- `Fetch_Meta`
18+
- `Top_Genes_Factor`
19+
- `Add_Mito_Ribo`
20+
- `Add_Cell_Complexity`
21+
- `DimPlot_LIGER`
22+
- `Variable_Features_ALL_LIGER`
23+
- `Feature_Present`
24+
25+
*New functions compatible with old and new style liger objects:*
26+
- Added new function `Add_Hemo` to add hemoglobin gene percentage for QC. Also added as parameter to `Add_Cell_QC_Metrics`. `Add_Hemo` supports all default species: (human, mouse, marmoset, zebrafish, rat, drosophila, rhesus macaque, and chicken) and works with both Seurat and liger objects.
27+
28+
*New scCustomize generics to function across both Seurat and Liger objects:*
29+
- `Add_Hemo` (see above).
30+
- `Rename_Clusters` now S3 generic for setting new active.ident (Seurat) or defaultCluster (Liger).
31+
32+
*New functions for Seurat and rliger v2.0.0+ only:*
33+
- Added new function `Find_Factor_Cor` to return correlation matrix between factor gene loadings from liger or Seurat object.
34+
- Added new function `Factor_Cor_Plot` to plot positive correlations from liger or Seurat object.
35+
36+
*Updated functions to recommend new rliger equivalents for users with rliger v2.0.0+:*
37+
- `as.LIGER`
38+
- `as.Seurat`
39+
40+
41+
**General scCustomize Updates:**
42+
*New functions:*
43+
- Added new function `Add_Hemo` to add hemoglobin gene percentage for QC. Also added as parameter to `Add_Cell_QC_Metrics`. `Add_Hemo` supports all default species: (human, mouse, marmoset, zebrafish, rat, drosophila, and rhesus macaque) and works with both Seurat and liger objects.
44+
- Added new function `seq_zeros()` to create sequences with preceding zeros.
45+
- Added new function `Read_Metrics_CellBender` to read in the summary metrics csv file produced by CellBender. Can either read all metrics files from parent directory of output folders or a single metrics file.
46+
- Added `Updated_MGI_Symbols` to check for update gene names/symbols in mouse data ([#202](https://github.com/samuel-marsh/scCustomize/issues/202)).
47+
- Added plotting function `Proportion_Plot` to plot pie chart or bar chart of proportion (or total counts) of cells in each identity class.
48+
- Added new function `Random_Cells_Downsample` to return either a vector or list with randomly downsampled cells for each identity class.
49+
- Added new function `Cells_per_Sample` to quickly return data.frame with just number of cells per sample.
50+
51+
*Updated functions:*
52+
- Added new parameters `data_name` and `overwrite` to `Add_Alt_Feature_ID` to support new storage location.
53+
- Added `cells` parameter explicitly to `FeatureScatter_scCustom`.
54+
- Added Chicken (Gallus gallus) to default species for QC functions. Thanks @dpearton; ([#176](https://github.com/samuel-marsh/scCustomize/issues/176)).
55+
- Added new plotting function `SpatialDimPlot_scCustom`. Thanks for encouragement @puapinyoying @nina-hahn ([#160](https://github.com/samuel-marsh/scCustomize/issues/160)).
56+
- Added ability of `Read_Metrics_10X` to read a single metrics csv file and return data formatted the same way as when reading multiple files.
57+
- Added parameter `cutoff_line_width` to the `QC_Plot_*` family of plots to control line thickness of cutoff lines.
58+
- `Cluster_Stats_All_Samples` now returns data.frame with row order reflecting the frequency of cells.
59+
- `Add_Mito_Ribo` now supports datasets aligned to multi-species reference genomes ([#184](https://github.com/samuel-marsh/scCustomize/issues/184)).
60+
- Added parameter `add_prop_plot` to `DimPlot_scCustom` to return plot showing number or percent of cells per identity along with the DimPlot.
61+
- Added optional parameter `colors_use_assay2` to `FeaturePlot_DualAssay` which allows for specification of different palettes for the two plots ([#182](https://github.com/samuel-marsh/scCustomize/issues/182)).
62+
- Added new folder and scripts (see "data-raw/" on GitHub) detailing the creation of gene lists used in `Add_Cell_QC_Metrics`.
63+
- Added ensembl ID support for percent hemoglobin, msigdb, and IEG gene sets ([#186](https://github.com/samuel-marsh/scCustomize/issues/186)).
64+
- Add verbosity parameter to `Store_Misc_Info_Seurat` and `Store_Palette_Seurat`.
65+
- Explicitly reveal the `reduction` parameter in `Cluster_Highlight_Plot` and `Meta_Highlight_Plot` ([#198](https://github.com/samuel-marsh/scCustomize/issues/198)).
66+
- Added `show_row_names` `show_column_names`, `column_names_side`, `row_names_side`, `legend_position`, `legend_orientation`, `show_ident_legend`, and `show_ident_colors` parameters to `Clustered_DotPlot`. Thanks for idea and code @johnminglu ([#199](https://github.com/samuel-marsh/scCustomize/issues/199)).
67+
- Updated `Split_Vector` to allow user to specify number of chunks or size of chunks for splitting vector.
68+
- Update `RenameClusters` with additional parameters to enable storage of both old idents and new idents in meta.data within the function.
69+
- Update `Add_Cell_QC_Metrics.Seurat` to explicitly reveal `list_species_names` parameter.
70+
- Added new vignette for spatial plotting.
71+
- Added new and expanded vignette on use of object QC functions for better clarity on these functions and their uses (previously was part of QC Plotting & Helpers/Utilities Vignettes). Plotting elements of QC Plotting vignette are unchanged.
72+
73+
74+
## Changed
75+
- **BREAKING CHANGES** `Add_Top_Gene_Pct_Seurat` is now S3 generic that works with both Seurat and liger objects and has been renamed `Add_Top_Gene_Pct`.
76+
- `Add_Cell_QC_Metrics` is now S3 generic and works with both Seurat and liger objects.
77+
- Changed storage location for `Add_Alt_Feature_ID` to `@misc` slot of object for safer storage across object filtering.
78+
- Added error check in `as.anndata` to explicitly check for installation of anndata before starting conversion ([#162](https://github.com/samuel-marsh/scCustomize/issues/162)).
79+
- Updated `Plot_Median_Genes`, `Plot_Median_UMIs`, `Plot_Median_Mito`, `Plot_Median_Other`, `Plot_Cells_per_Sample` to understand "ident" as grouping variable.
80+
- Updated `Store_Misc_Info_Seurat` to use Seurat accessor/setter function `Seurat::Misc()`.
81+
- Updated documentation for `sample_names` in `Read_CellBender_h5_Multi_File` to clarify parameter behavior (related to ([#208](https://github.com/samuel-marsh/scCustomize/issues/208))).
82+
- Updated `Read_Metrics_10X` to support adjusts to metrics summary format and metric names in output from Cell Ranger v9+.
83+
- Some reorganization of R/ directory/scripts.
84+
85+
86+
## Fixes
87+
- Nebulosa plotting functions `Plot_Density_Custom` and `Plot_Density_Joint_Only` have been re-enabled for users with ggplot2 v3.5.0 following Nebulosa v1.12.1 update patch.
88+
- Fixed bug causing error in `Add_Cell_QC_Metrics` when `overwrite = TRUE` ([#165](https://github.com/samuel-marsh/scCustomize/issues/165)).
89+
- Fixed wrong description of parameter in manual entry for `DotPlot_scCustom` ([#158](https://github.com/samuel-marsh/scCustomize/issues/158)).
90+
- Fixed several potential errors in `as.anndata` from Seurat conversion that previously caused failures ([#168](https://github.com/samuel-marsh/scCustomize/issues/168)).
91+
- Fixed errors in `Create_Cluster_Annotation_File` if for file path and csv name errors.
92+
- Fixed error when using `plot_median` and more than one feature in `VlnPlot_scCustom` ([#169](https://github.com/samuel-marsh/scCustomize/issues/169)).
93+
- Fixed bug while collecting legends for `DimPlot_scCustom` due to changes in guides updated with ggplot2 v3.5.0 ([#171](https://github.com/samuel-marsh/scCustomize/issues/171)).
94+
- Fixed error in `Add_Sample_Meta` that still errored when setting `na_ok = TRUE`.
95+
- Fixed errors in `Plot_Median_*` family that caused issues when `group_by` parameter was NULL.
96+
- Fixed errors in `FeaturePlot_scCustom` when setting `combine = FALSE`.
97+
- Fixed bug in `DimPlot_scCustom` that could cause blank plot when rasterizing points.
98+
- Fixed bug in `MAD_Stats` that didn't respect `mad_num` parameter ([#183](https://github.com/samuel-marsh/scCustomize/issues/183)).
99+
- Fixed bugs in `MAD_Stats` that could cause issues if `mad_num` was less than or equal to 0 and returned error if setting `group_by_var` to "ident".
100+
- Replaced lingering instances of deprecated tidyr code .data[["var"]] with update `all_of`/`any_of` syntax.
101+
- Fixed issue that could occur with some meta data modifying functions due to column name collisions in internals of function ([#193](https://github.com/samuel-marsh/scCustomize/issues/193)).
102+
- Fixed issue that caused error when using `Cluster_Highlight_Plot` with `split.by` parameter ([#201](https://github.com/samuel-marsh/scCustomize/issues/201)).
103+
- Added check and informative error message to `Convert_Assay` ([#205](https://github.com/samuel-marsh/scCustomize/issues/205)).
104+
- Fixed issue with anndata conversion and Seurat V5 objects ([#195](https://github.com/samuel-marsh/scCustomize/issues/195)).
105+
- Fixed issue with `Updated_HGNC_Symbols` due to change in URL path for gene names ([#209](https://github.com/samuel-marsh/scCustomize/issues/209)).
106+
- Fixed bug in `DimPlot_scCustom` when `split.by` and `label.box = TRUE`.
107+
- Fixed bug in `DiscretePalette_scCustom` that didn't error when supplying invalid palette names.
108+
- Fixed bug in `DimPlot_LIGER` that provided uniformative error message when changing the default cluster ident.
109+
- Spelling and style fixes. Thanks @kew24.
110+
111+
112+
1113
# scCustomize 2.1.2 (2024-02-27)
2114
## Added
3115
- None.

R/Color_Palettes.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,20 @@ DiscretePalette_scCustomize <- function(
420420
shuffle_pal = FALSE,
421421
seed = 123
422422
) {
423+
palette_options <- c("alphabet", "alphabet2", "glasbey", "polychrome", "stepped", "ditto_seq", "varibow")
424+
423425
if (is.null(x = palette)) {
424426
cli_abort(message = c("Must specify a palette to return colors.",
425-
"i" = "{.code palette} options are: {.field {names(palette_list)}}")
427+
"i" = "{.code palette} options are: {.field {names(palette_options)}}")
426428
)
427429
}
428430

431+
# check palette valid
432+
if (!palette %in% palette_options) {
433+
cli_abort(message = c("The specified palette: {.field {palette}} is not valid.",
434+
"i" = "Valid palettes are: {.val {palette_options}}"))
435+
}
436+
429437
# dittoseq check
430438
if (palette == "ditto_seq") {
431439
dittoseq_check <- is_installed(pkg = "dittoSeq")
@@ -510,6 +518,9 @@ scCustomize_Palette <- function(
510518
if (isTRUE(x = ggplot_default_colors)) {
511519
colors_use <- Hue_Pal(num_colors = num_groups)
512520
} else {
521+
if (num_groups < 36 && color_seed != 123) {
522+
cli_inform(message = "{.code color_seed} only applies if number of groups plotted is greater than 36.")
523+
}
513524
if (num_groups == 1) {
514525
colors_use <- "dodgerblue"
515526
}

0 commit comments

Comments
 (0)