hyunhwan-jeong / CB2

CB2 is an R package which provides functions for hit gene identification and quantification of sgRNA (single-guided RNA) abundances for CRISPR (Clustered Regularly Interspaced Short Palindromic Repeats) pooled screen data analysis. Details are in Jeong et al. (2019) <doi:10.1101/gr.245571.118> and Baggerly et al. (2003) <doi:10.1093/bioinformatics/btg173>.
https://cran.r-project.org/web/packages/CB2/index.html
Other
7 stars 1 forks source link

plot_count_distribution add export option #7

Closed AMChalkie closed 4 years ago

AMChalkie commented 4 years ago

add option to return the ggplot object to user

hyunhwan-jeong commented 4 years ago

Instead of adding a parameter, you can assign the output of the function to a variable to have a ggplot object, like the following code.

library(CB2)
data(Evers_CRISPRn_RT112)
cpm <- get_CPM(Evers_CRISPRn_RT112$count)
obj <- plot_count_distribution(cpm, Evers_CRISPRn_RT112$design)
summary(obj)

The output of the code shows that obj is a ggplot object.

data: sgRNA, sample_name, count, group [5766x4]
mapping:  x = ~count
faceting: <ggproto object: Class FacetWrap, Facet, gg>
    compute_layout: function
    draw_back: function
    draw_front: function
    draw_labels: function
    draw_panels: function
    finish_data: function
    init_scales: function
    map_data: function
    params: list
    setup_data: function
    setup_params: function
    shrink: TRUE
    train_scales: function
    vars: function
    super:  <ggproto object: Class FacetWrap, Facet, gg>
-----------------------------------
mapping: fill = ~group 
geom_density: na.rm = FALSE
stat_density: na.rm = FALSE
position_identity 

Correct me if I am wrong.

Thank you,

Hyun-Hwan Jeong