cnio-bu / beyondcell

Beyondcell is a computational methodology for identifying tumour cell subpopulations with distinct drug responses in single-cell RNA-seq and Spatial Transcriptomics data.
Other
40 stars 4 forks source link

Table of Beyondcell scores for a specific drug or signature for each cell barcodes #133

Closed tc86 closed 1 year ago

tc86 commented 1 year ago

Hi, Thank you for developing this excellent tool. I have been following the tutorial, and the tool is working great for me. I have a question regarding the data used to create the umap for specific drugs/signatures from the "bc" object. Is there a way I can extract a table from the beyond cell object with scores for each cell for a specific signature I'm interested in?

For example, in the visualization tutorial, the following UMAP is drawn.

Screenshot 2023-05-26 153644

I want the data used to create this UMAP but in a table form. I will appreciate any help you could provide on this matter. Thanks!

mj-jimenez commented 1 year ago

Hi @tc86!

Thank you very much for trying beyondcell!

Yes, there is a simple way to do this. Beyondcell objects have several slots that store scores (@data, @normalized and @scaled). The normalized scores are the ones used to compute the UMAP and to do any downstream analyses. To extract them, just do the following:

# Get the full matrix of normalized scores
norm_scores <- bc@normalized

# Get the normalized scores for all single-cells and a specific signature
bortezomib_18868 <- norm_scores["sig_18868", ]

If you know the name of the drug you are looking for and want to find the signature ID to subset by, you can use FindDrugs function, as explained in the tutorial:

FindDrugs(bc, x = "bortezomib")

Please note that the UMAP plot is colored using the @scaled slot. If you want to reproduce the image above, you will also need those. Moreover, the scale middle point is the Switch Point, which can be found in the slot @switch.point.

# Get the scaled scores for all single-cells and a specific signature
bortezomib_18868_scaled <- bc@scaled["sig_18868", ]

# Get the switch point for this signature
bortezomib_18868_sp <- bc@switch.point["sig_18868"]

Finally, the object drugInfo that is loaded with the beyondcell library might be useful for you. It contains information about drug synonyms, targets and mechanisms of action.

Hope this helps!

Best regards, The beyondcell team

tc86 commented 1 year ago

Thank you so much for the detailed comment! It answered my query perfectly