Skip to content

Commit 44354f3

Browse files
authored
Merge pull request #112 from samuel-marsh/release/1.1.2
Release/1.1.2
2 parents d08268d + 74cc741 commit 44354f3

File tree

238 files changed

+2783
-854
lines changed

Some content is hidden

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

238 files changed

+2783
-854
lines changed

CRAN-SUBMISSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 1.1.1
2-
Date: 2023-01-13 15:02:59 UTC
3-
SHA: a78523f9f8648a034a64a2f7455ddb8acfbca410
1+
Version: 1.1.2
2+
Date: 2023-07-18 18:13:59 UTC
3+
SHA: 9546b0eb9894cba46d6c20670e58c60ee3e185cb

DESCRIPTION

Lines changed: 2 additions & 2 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>.
5-
Version: 1.1.1
6-
Date: 2023-01-13
5+
Version: 1.1.2
6+
Date: 2023-07-18
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"),

NAMESPACE

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export(DimPlot_LIGER)
3333
export(DimPlot_scCustom)
3434
export(DiscretePalette_scCustomize)
3535
export(DotPlot_scCustom)
36+
export(Extract_Modality)
3637
export(Extract_Sample_Meta)
3738
export(Extract_Top_Markers)
3839
export(FeaturePlot_DualAssay)
@@ -53,6 +54,7 @@ export(Liger_to_Seurat)
5354
export(Median_Stats)
5455
export(Merge_Seurat_List)
5556
export(Merge_Sparse_Data_All)
57+
export(Merge_Sparse_Multimodal_All)
5658
export(Meta_Highlight_Plot)
5759
export(Meta_Numeric)
5860
export(Meta_Present)
@@ -90,6 +92,7 @@ export(Read_CellBender_h5_Multi_Directory)
9092
export(Read_CellBender_h5_Multi_File)
9193
export(Read_GEO_Delim)
9294
export(Read_Metrics_10X)
95+
export(Reduction_Loading_Present)
9396
export(Rename_Clusters)
9497
export(Replace_Suffix)
9598
export(Seq_QC_Plot_Alignment_Combined)
@@ -157,6 +160,7 @@ importFrom(SeuratObject,PackageCheck)
157160
importFrom(circlize,colorRamp2)
158161
importFrom(cowplot,theme_cowplot)
159162
importFrom(data.table,fread)
163+
importFrom(dplyr,across)
160164
importFrom(dplyr,all_of)
161165
importFrom(dplyr,any_of)
162166
importFrom(dplyr,arrange)
@@ -169,14 +173,12 @@ importFrom(dplyr,intersect)
169173
importFrom(dplyr,left_join)
170174
importFrom(dplyr,mutate)
171175
importFrom(dplyr,n)
172-
importFrom(dplyr,one_of)
173176
importFrom(dplyr,pull)
174177
importFrom(dplyr,rename)
175178
importFrom(dplyr,select)
176-
importFrom(dplyr,select_at)
177179
importFrom(dplyr,slice)
178180
importFrom(dplyr,slice_max)
179-
importFrom(dplyr,summarise_at)
181+
importFrom(dplyr,summarise)
180182
importFrom(dplyr,summarize)
181183
importFrom(forcats,fct_relevel)
182184
importFrom(ggbeeswarm,geom_quasirandom)
@@ -195,6 +197,7 @@ importFrom(janitor,adorn_totals)
195197
importFrom(lifecycle,deprecated)
196198
importFrom(magrittr,"%>%")
197199
importFrom(methods,as)
200+
importFrom(methods,hasArg)
198201
importFrom(methods,new)
199202
importFrom(methods,slot)
200203
importFrom(paletteer,paletteer_c)
@@ -203,7 +206,6 @@ importFrom(patchwork,plot_annotation)
203206
importFrom(patchwork,plot_layout)
204207
importFrom(patchwork,wrap_plots)
205208
importFrom(pbapply,pblapply)
206-
importFrom(pbapply,pbmapply)
207209
importFrom(pbapply,pboptions)
208210
importFrom(purrr,discard)
209211
importFrom(purrr,keep)

NEWS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
# scCustomize 1.1.2 (2023-07-18)
2+
## Added
3+
- Added `aspect_ratio` parameter to all dimensionality reduction plots to control axes ratio of output plot.
4+
- Added `plot_median` and `median_size` parameters to `QC_Plots_*` functions.
5+
- Added `split_collect` parameter to `FeaturePlot_scCustom` to collect all guides when using `split.by` for a single feature ([#94](https://github.com/samuel-marsh/scCustomize/issues/94)).
6+
- Added new parameters to `Clustered_DotPlot` to allow modification of sizes of column text labels, legend text labels, and legend title labels ([#96](https://github.com/samuel-marsh/scCustomize/issues/96)).
7+
- Added new function `Merge_Sparse_Multimodal_All` for merging multi-modal data (1 matrix per modality) ([#104](https://github.com/samuel-marsh/scCustomize/issues/104)).
8+
- Added new parameter to `Clustered_DotPlot` named `row_label_fontface` to allow control of fontface used for row labels ([#103](https://github.com/samuel-marsh/scCustomize/issues/103)).
9+
- Added helper utility `Reduction_Loading_Present`, in part to fix issue with `FeaturePlot_scCustom` and internal feature checking.
10+
- Added ability to turn off feature/ident clustering in `Clustered_DotPlot` using new parameters: `cluster_feature`, `cluster_ident` ([#106](https://github.com/samuel-marsh/scCustomize/issues/106)).
11+
- Added `dot_size` parameter to statistics plotting functions `Plot_Cells_per_Sample` and `Plot_Median_*` family.
12+
- Added new parameter `no_legend` to `Iterate_Meta_Highlight_Plot` to allow for plotting with a plot title instead of plot legend ([#108](https://github.com/samuel-marsh/scCustomize/issues/108)).
13+
14+
15+
## Changed
16+
- Moved `QC_Plots_Feature` to use `VlnPlot_scCustom` under the hood like rest of `QC_Plots_*` functions.
17+
- Renamed parameter `abort` in `Meta_Present` to `return_none` to align with `Gene_Present` and `Reduction_Loading_Present`.
18+
- Replace superseded dplyr syntax/functionality `summarise_at`, `select(.data[[var]])`, and `rename(.data[[var]])` with current dplyr syntax.
19+
- Internal rewrite of plotting sections within `Iterate_Cluster_Highlight_Plot` and `Iterate_Meta_Highlight_Plot` to align with recent updates to base `Cluster_Highlight_Plot` and `Meta_Highlight_Plot` functions.
20+
21+
22+
## Fixes
23+
- Fixed `QC_Plots_Feature` to respect parameters when passing to `VlnPlot` ([#91](https://github.com/samuel-marsh/scCustomize/issues/91)).
24+
- Fixed `Read_CellBender_h5_*` functions to support CellBender outputs from STARsolo- or Cell Ranger (pre-V3)-processed data ([#99](https://github.com/samuel-marsh/scCustomize/issues/99)).
25+
- Fixed `FeaturePlot_scCustom` to allow for plotting of dimensionality reduction loadings ([#97](https://github.com/samuel-marsh/scCustomize/issues/97)).
26+
- Fixed `Read10X_Multi_Directory` and `Read10X_h5_Multi_Directory` to support files processed with Cell Ranger `multi` pipeline.
27+
- Fixed bug in `Merge_Seurat_List` that prevented `add.cell.id` from adding correct cell name prefixes ([#113](https://github.com/samuel-marsh/scCustomize/issues/113)).
28+
29+
30+
131
# scCustomize 1.1.1 (2023-01-13)
232
## Added
333
- Added `label_color_num` parameter to `PalettePlot` allow control of color labeling.
@@ -21,6 +51,7 @@
2151
- Updated out-dated documentation for number of package functions.
2252
- Typo/styling fixes.
2353

54+
2455
# scCustomize 1.1.0 (2022-12-22)
2556
## Added
2657
- Added `merge` parameter to `Read10X_GEO`, `Read10X_h5_GEO`, `Read_GEO_Delim` and `Read_CellBender_h5_Multi_File`.

R/Color_Palettes.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ Single_Color_Palette <- function(pal_color,
182182
"#000000"
183183
)
184184
)
185-
if (!pal_color %in% names(brewer_single_modified)) {
185+
if (!pal_color %in% names(x = brewer_single_modified)) {
186186
cli_abort(message = c("Paleete name not found.",
187187
"i" = "Palette name not found. Please select one of following palette options: {.field 'reds', 'blues', 'greens', 'purples', or 'grays'}")
188188
)
189189
}
190190
set.seed(seed = seed_use)
191191
pal_use <- brewer_single_modified[[pal_color]]
192-
output_pal <- sample(pal_use, size = num_colors)
192+
output_pal <- sample(x = pal_use, size = num_colors)
193193
return(output_pal)
194194
}
195195

@@ -216,7 +216,7 @@ NavyAndOrange <- function(
216216
) {
217217
navy_orange <- c("navy", "orange")
218218
if (flip_order) {
219-
navy_orange <- rev(navy_orange)
219+
navy_orange <- rev(x = navy_orange)
220220
}
221221
return(navy_orange)
222222
}
@@ -356,8 +356,8 @@ ColorBlind_Pal <- function(
356356
varibow_scCustom <- function(
357357
n_colors
358358
) {
359-
sats <- rep_len(c(0.55,0.7,0.85,1),length.out = n_colors)
360-
vals <- rep_len(c(1,0.8,0.6),length.out = n_colors)
359+
sats <- rep_len(x = c(0.55,0.7,0.85,1), length.out = n_colors)
360+
vals <- rep_len(x = c(1,0.8,0.6), length.out = n_colors)
361361
rainbow(n_colors, s = sats, v = vals)
362362
}
363363

@@ -469,7 +469,7 @@ DiscretePalette_scCustomize <- function(
469469
}
470470
if (shuffle_pal) {
471471
set.seed(seed = seed)
472-
palette_out <- sample(palette_out[1:num_colors])
472+
palette_out <- sample(x = palette_out[1:num_colors])
473473
} else {
474474
palette_out <- palette_out[1:num_colors]
475475
}

R/Internal_Utilities.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ glue_collapse_scCustom <- function(
225225

226226
#' Perform Feature and Meta Checks before plotting
227227
#'
228-
#' Wraps the `Gene_Present`, `Meta_Present`, and `Case_Check` into single function to perform feature
229-
#' checks before plotting.
228+
#' Wraps the `Gene_Present`, `Meta_Present`, `Reduction_Loading_Present`, and `Case_Check` into
229+
#' single function to perform feature checks before plotting.
230230
#'
231231
#' @param object Seurat object
232232
#' @param features vector of features and/or meta data variables to plot.
@@ -245,11 +245,13 @@ Feature_PreCheck <- function(
245245
# Check features and meta to determine which features present
246246
features_list <- Gene_Present(data = object, gene_list = features, omit_warn = FALSE, print_msg = FALSE, case_check_msg = FALSE, return_none = TRUE)
247247

248-
meta_list <- Meta_Present(seurat_object = object, meta_col_names = features_list[[2]], omit_warn = FALSE, print_msg = FALSE, abort = FALSE)
248+
meta_list <- Meta_Present(seurat_object = object, meta_col_names = features_list[[2]], omit_warn = FALSE, print_msg = FALSE, return_none = TRUE)
249249

250-
all_not_found_features <- meta_list[[2]]
250+
reduction_list <- Reduction_Loading_Present(seurat_object = object, reduction_names = meta_list[[2]], omit_warn = FALSE, print_msg = FALSE, return_none = TRUE)
251251

252-
all_found_features <- c(features_list[[1]], meta_list[[1]])
252+
all_not_found_features <- reduction_list[[2]]
253+
254+
all_found_features <- c(features_list[[1]], meta_list[[1]], reduction_list[[1]])
253255

254256
# Stop if no features found
255257
if (length(x = all_found_features) < 1) {

R/LIGER_Plotting.R

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#' @param shuffle_seed Sets the seed if randomly shuffling the order of points.
1919
#' @param reduction_label What to label the x and y axes of resulting plots. LIGER does not store name of
2020
#' technique and therefore needs to be set manually. Default is "UMAP".
21+
#' @param aspect_ratio Control the aspect ratio (y:x axes ratio length). Must be numeric value;
22+
#' Default is NULL.
2123
#' @param label logical. Whether or not to label the clusters. ONLY applies to plotting by cluster. Default is TRUE.
2224
#' @param label_size size of cluster labels.
2325
#' @param label_repel logical. Whether to repel cluster labels from each other if plotting by
@@ -61,6 +63,7 @@ DimPlot_LIGER <- function(
6163
shuffle = TRUE,
6264
shuffle_seed = 1,
6365
reduction_label = "UMAP",
66+
aspect_ratio = NULL,
6467
label = TRUE,
6568
label_size = NA,
6669
label_repel = FALSE,
@@ -170,6 +173,15 @@ DimPlot_LIGER <- function(
170173
shuffle_seed = shuffle_seed)
171174

172175
p3 <- wrap_plots(p1 + p2)
176+
177+
# Aspect ratio changes
178+
if (!is.null(x = aspect_ratio)) {
179+
if (!is.numeric(x = aspect_ratio)) {
180+
cli_abort(message = "{.code aspect_ratio} must be a {.field numeric} value.")
181+
}
182+
p3 <- p3 & theme(aspect.ratio = aspect_ratio)
183+
}
184+
173185
return(p3)
174186
}
175187

@@ -192,6 +204,14 @@ DimPlot_LIGER <- function(
192204
label_color = label_color,
193205
label = label,
194206
color_seed = color_seed)
207+
# Aspect ratio changes
208+
if (!is.null(x = aspect_ratio)) {
209+
if (!is.numeric(x = aspect_ratio)) {
210+
cli_abort(message = "{.code aspect_ratio} must be a {.field numeric} value.")
211+
}
212+
p1 <- p1 & theme(aspect.ratio = aspect_ratio)
213+
}
214+
195215
return(p1)
196216
}
197217

@@ -210,6 +230,14 @@ DimPlot_LIGER <- function(
210230
split_by = split_by,
211231
shuffle_seed = shuffle_seed,
212232
color_seed = color_seed)
233+
# Aspect ratio changes
234+
if (!is.null(x = aspect_ratio)) {
235+
if (!is.numeric(x = aspect_ratio)) {
236+
cli_abort(message = "{.code aspect_ratio} must be a {.field numeric} value.")
237+
}
238+
p2 <- p2 & theme(aspect.ratio = aspect_ratio)
239+
}
240+
213241
return(p2)
214242
}
215243
}
@@ -330,7 +358,7 @@ plotFactors_scCustom <- function(
330358
"i" = "The number of datasets provided to {.code reorder_datasets} ({.field {length(x = reorder_datasets)}}) does not match number of datasets in LIGER object ({.field {length(x = levels(x = levels(liger_object@cell.data$dataset)))}}).")
331359
)
332360
} else {
333-
if (!all(levels(liger_object@cell.data$dataset) %in% reorder_datasets)) {
361+
if (!all(levels(x = liger_object@cell.data$dataset) %in% reorder_datasets)) {
334362
cli_abort(message = c("Error reordering datasets (name mismatch).",
335363
"*" = "Dataset names provided to {.code reorder_datasets} do not match names of datasets in LIGER object.",
336364
"i" = "Please check spelling.")
@@ -379,16 +407,16 @@ plotFactors_scCustom <- function(
379407

380408
# Get Data and Plot Factors
381409
cli_inform(message = "{.field Generating plots}")
382-
k <- ncol(liger_object@H.norm)
410+
k <- ncol(x = liger_object@H.norm)
383411
pb <- txtProgressBar(min = 0, max = k, style = 3)
384-
W <- t(liger_object@W)
385-
rownames(W) <- colnames(liger_object@scale.data[[1]])
412+
W <- t(x = liger_object@W)
413+
rownames(x = W) <- colnames(x = liger_object@scale.data[[1]])
386414
Hs_norm <- liger_object@H.norm
387415
H_raw = do.call(rbind, liger_object@H)
388416
plot_list = list()
389417
tsne_list = list()
390418
for (i in 1:k) {
391-
top_genes.W <- rownames(W)[order(W[, i], decreasing = T)[1:num_genes]]
419+
top_genes.W <- rownames(x = W)[order(W[, i], decreasing = T)[1:num_genes]]
392420
top_genes.W.string <- paste0(top_genes.W, collapse = ", ")
393421
factor_textstring <- paste0("Factor", i)
394422
plot_title1 <- paste(factor_textstring, "\n", top_genes.W.string, "\n")
@@ -461,7 +489,7 @@ plotFactors_scCustom <- function(
461489
if (plot_dimreduc) {
462490
tsne_df <- data.frame(Hs_norm[, i], liger_object@tsne.coords)
463491
factorlab <- paste0("Factor", i)
464-
colnames(tsne_df) <- c(factorlab, x_axis_label, y_axis_label)
492+
colnames(x = tsne_df) <- c(factorlab, x_axis_label, y_axis_label)
465493

466494
if (order) {
467495
tsne_df <- tsne_df[order(tsne_df[,1], decreasing = FALSE),]

0 commit comments

Comments
 (0)