Set different color palettes to be used for different assays in FeaturePlot_DualAssay · Issue #182 · samuel-marsh/scCustomize (original) (raw)

Hi,
Thank you os much for this amazing package. It has made life easier by a lot.
I would like to request for an enhancement to an already avaliable function, FeaturePlot_DualAssay.
For now, both assays use same color palette provided by colors_use. I would like to visualize this using 2 independent color palettes.
I modified the original function and manually provided the colors and it is working as long as I am not splitting the Seurat object.

DefaultAssay(object = seurat_object) <- assay1

plot_raw <- FeaturePlot_scCustom(seurat_object = seurat_object, features = features, layer = layer, colors_use = viridis_plasma_dark_high, na_color = na_color, na_cutoff = na_cutoff, order = order, pt.size = pt.size, reduction = reduction, raster = raster, alpha_exp = alpha_exp, alpha_na_exp = alpha_na_exp, raster.dpi = raster.dpi, ...) & labs(color = assay1)

Change to cell bender and plot

DefaultAssay(object = seurat_object) <- assay2

plot_cell_bender <- FeaturePlot_scCustom(seurat_object = seurat_object, features = features, layer = layer, colors_use = viridis_dark_high, na_color = na_color, na_cutoff = na_cutoff, order = order, pt.size = pt.size, reduction = reduction, raster = raster, alpha_exp = alpha_exp, alpha_na_exp = alpha_na_exp, raster.dpi = raster.dpi, ...) & labs(color = assay2)

The moment I try to split, like this, FeaturePlot_DualAssay_col(combined, features = kp, assay1 = "SCT", assay2 = "gene.activity", split.by = "Origin", pt.size = 0.5, reduction = "wnn.umap", na_color = "lightgray", num_columns = 1) it gives me the following error:

Error in match.arg(arg = layer, choices = c("counts", "data", "scale.data")): 'arg' must be NULL or a character vector
Traceback:

  1. FeaturePlot_DualAssay_col(combined, features = kp, assay1 = "SCT",

. assay2 = "gene.activity", split.by = "Origin", pt.size = 0.5,
. reduction = "wnn.umap", na_color = "lightgray", num_columns = 1,
. split_seurat = T)

  1. FeaturePlot_scCustom(seurat_object = seurat_object, features = features,
    . layer = layer, colors_use = viridis_plasma_dark_high, na_color = na_color,
    . na_cutoff = na_cutoff, order = order, pt.size = pt.size,
    . reduction = reduction, raster = raster, alpha_exp = alpha_exp,
    . alpha_na_exp = alpha_na_exp, raster.dpi = raster.dpi, ...) # at line 76 of file
  2. FetchData(object = seurat_object, vars = all_found_features,
    . layer = layer)
  3. FetchData.Seurat(object = seurat_object, vars = all_found_features,
    . layer = layer)
  4. FetchData(object = object[[DefaultAssay(object = object)]], vars = default.vars,
    . cells = cells, layer = layer, ...)
  1. FetchData.Assay(object = object[[DefaultAssay(object = object)]],
    . vars = default.vars, cells = cells, layer = layer, ...)
  1. match.arg(arg = layer, choices = c("counts", "data", "scale.data"))
  2. stop("'arg' must be NULL or a character vector")