[go: nahoru, domu]

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

How to reload the "extracted R code" ? #569

Closed
eroesti opened this issue Jul 29, 2021 · 2 comments
Closed

How to reload the "extracted R code" ? #569

eroesti opened this issue Jul 29, 2021 · 2 comments

Comments

@eroesti
Copy link
eroesti commented Jul 29, 2021

Hi, thanks for developing the app, is perfect for visualisation for CITE-seq data!

I have a question regarding the reload of the app with the extracted R code. Once I choose the only plot I want to visualise with the features I like, and copy the R code, I am unable to restart it. Could you please help me to understand where I am wrong ? Thanks a lot in advance!!

My code is the following:

My sce is loaded:
sce <- readRDS("shiny_app_v1.rds")

Normally to launch the app I would do the following command:
app <- iSEE(sce)
followed by
shiny::runApp(app)

Now my extracted R code is the following:

## The following list of commands will generate the plots created in iSEE
## Copy them into a script or an R session containing your SingleCellExperiment.
## All commands below refer to your SingleCellExperiment object as `se`.

se <- sce
colormap <- ExperimentColorMap()
colormap <- synchronizeAssays(colormap, se)
all_contents <- list()

################################################################################
# Defining brushes
################################################################################

all_active <- list()
all_active[['FeatureAssayPlot1']] <- list()

################################################################################
## Feature assay plot 1
################################################################################


plot.data <- data.frame(Y=assay(se, "logcounts")["CD8", ], row.names=colnames(se))
plot.data$X <- assay(se, "logcounts")["CD4", ];

plot.data$ColorBy <- assay(se, "logcounts")["CD16", ];

# Avoid visual biases from default ordering by shuffling the points
set.seed(89869);
plot.data <- plot.data[sample(nrow(plot.data)),,drop=FALSE];

dot.plot <- ggplot() +
  geom_point(aes(x=X, y=Y, color=ColorBy), alpha=1, plot.data, size=1) +
  labs(x="CD4 (logcounts)", y="CD8 (logcounts)", color="CD16\n(logcounts)", title="CD8 vs CD4") +
  coord_cartesian(xlim=range(plot.data$X, na.rm=TRUE),
                  ylim=range(plot.data$Y, na.rm=TRUE), expand=TRUE) +
  scale_color_gradientn(colors=assayColorMap(colormap, "logcounts", discrete=FALSE)(21), na.value='grey50', limits=range(plot.data$ColorBy, na.rm=TRUE)) +
  theme_bw() +
  theme(legend.position='bottom', legend.box='vertical', legend.text=element_text(size=9), legend.title=element_text(size=11),
        axis.text=element_text(size=10), axis.title=element_text(size=12), title=element_text(size=12))

# Saving data for transmission
all_contents[['FeatureAssayPlot1']] <- plot.data

In which order exactly do I need to write the commands in order to launch the app with the modified features?
I tried to run the code and launch the app with the same command shiny::runApp(app), however how do I have to define app <- iSEE(...) ?

Apologies for the beginner question ^^' and thanks again!

@csoneson
Copy link
Member

The code above (obtained by clicking on 'Extract the R code') can be used to recreate all the plots shown in the app in an interactive R session. To export the code required to start the app in a given state, you need to instead click on 'Display panel settings'. This will start with something like

initial <- list()

...

and defines the initial settings for all panels.

If you run that code, and then do

app <- iSEE(sce, initial = initial)
shiny::runApp(app)

the app should start in the intended configuration.

@eroesti
Copy link
Author
eroesti commented Jul 29, 2021

Thanks a lot! It worked perfectly!

@eroesti eroesti closed this as completed Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants