Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CellBender genes removed? #70

Closed
giorgiatosoni opened this issue Oct 30, 2022 · 4 comments
Closed

CellBender genes removed? #70

giorgiatosoni opened this issue Oct 30, 2022 · 4 comments
Assignees
Labels
enhancement Enhance existing function/feature New Feature New feature to add

Comments

@giorgiatosoni
Copy link

Hi,

Thank you very much for the additional features added to the new release, I find the CellBender vignette very useful!

I was wondering what would be a way to see which genes are removed (nFeature_Diff) in the dual assay. The dual assay plotting is already very useful to understand if CellBender is doing a great job, however, it would be useful to have a quick way to understand what Cellbender did and what was considered as ambient RNA.

Thanks!

Giorgia

@samuel-marsh samuel-marsh self-assigned this Nov 1, 2022
@samuel-marsh samuel-marsh added enhancement Enhance existing function/feature New Feature New feature to add labels Nov 1, 2022
@samuel-marsh
Copy link
Owner

Hi Giorgia,

Yes totally makes sense. Working on function to do just that. Hope to push it to dev branch before end of the week.

Best,
Sam

@samuel-marsh
Copy link
Owner

Hi Giorgia,

Ok the functions are now present in develop branch (v1.0.0.0007).
Here's quick overview.

# Already present function (but now renamed).
# This will add two columns to meta.data slot (nFeature_Diff and nCount_Diff)
# These will be the numerical differences in features per cell and counts per cell between the two assays
dual_seurat <- Add_CellBender_Diff(seurat_object = dual_seurat, raw_assay_name = "RAW", cell_bender_assay_name = "RNA")

head(dual_seurat@meta.data)
                       orig.ident nCount_RNA nFeature_RNA nCount_RAW nFeature_RAW nFeature_Diff nCount_Diff
WT1_AAACCCAAGCGACCCT-1        WT1       9844         3423      10032         3481            58         188
WT1_AAACCCAAGGAGGCAG-1        WT1       9248         3477       9431         3531            54         183
WT1_AAACCCACACACCAGC-1        WT1       3207         1699       3472         1852           153         265
WT1_AAACCCACATCTGTTT-1        WT1      14328         3930      14572         3993            63         244
WT1_AAACCCAGTATTCTCT-1        WT1      12034         3911      12223         3958            47         189
WT1_AAACCCAGTCTTGGTA-1        WT1      11722         3933      11967         4024            91         245



# New Function #1
# Return data.frame with rowSums for each gene in dataset (features will be rownames)
# 4 columns Raw Counts, Cell Bender Counts, Count Difference, % Change
# by default data.frame returns sorted by % change.

diff_df <- CellBender_Feature_Diff(seurat_object = dual_seurat, raw_assay = "RAW", cell_bender_assay = "RNA")

head(diff_df)
        Raw_Counts CellBender_Counts Feature_Diff Pct_Diff
Gm42418     256834              3198       253636 98.75484
Uqcr11        1315                20         1295 98.47909
Gm48099        277                 5          272 98.19495
Tmsb4x        6010               116         5894 98.06988
Rps21         2597                61         2536 97.65114
Ndufa4        3960                94         3866 97.62626

tail(diff_df)
           Raw_Counts CellBender_Counts Feature_Diff Pct_Diff
Zfy2                6                 6            0        0
Gm21865            11                11            0        0
mt-Atp8            74                74            0        0
AC168977.1          8                 8            0        0
AC132444.5          9                 9            0        0
CT868723.1          9                 9            0        0



# New Function #2
# Visualize the results of `CellBender_Feature_Diff`
# Can plot either genes changed by XX% or a specific number of genes.
# optional parameters change change feature labeling and other plot parameters
# more optional parameters than those shown below.  Use `?CellBender_Diff_Plot` to see manual entry.

# plot default (features > 25% change)
p1 <- CellBender_Diff_Plot(feature_diff_df = diff_df)
# Only plot features changed more than 50%
p2 <- CellBender_Diff_Plot(feature_diff_df = diff_df, pct_diff_threshold = 50)
# Plot the top 500 changed genes regardless of the % change
p3 <- CellBender_Diff_Plot(feature_diff_df = diff_df, num_features = 500, pct_diff_threshold = NULL)
# Only plot text labels for the top 10 changed features
p4 <- CellBender_Diff_Plot(feature_diff_df = diff_df, num_labels = 10)
# Don't add text feature labels
p5 <- CellBender_Diff_Plot(feature_diff_df = test, labels = FALSE)
# Label a specific set of genes (Note these genes must be presented in the filtered (pct_diff_threshold or num_features data).
p6 <- CellBender_Diff_Plot(feature_diff_df = test, custom_labels = "Malat1")

library(patchwork)
(p1 + p2 + p3) / (p4 + p5 + p6)

cell_bender_plots

Let me know if you have any issues with new functions and I can reopen issue.
Best,
Sa,

@giorgiatosoni
Copy link
Author

That's so useful! Thank you very much! :)

@samuel-marsh
Copy link
Owner

No problem!! Definitely useful functions to have!

CellBender v3 (currently in alpha) includes some of this in output html summary but nice to have in R when creating objects etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhance existing function/feature New Feature New feature to add
Projects
None yet
Development

No branches or pull requests

2 participants