CRI-iAtlas / shiny-iatlas

An interactive web portal for exploring immuno-oncology data. This repo now superseded by iatlas-app
https://www.cri-iatlas.org
Apache License 2.0
47 stars 12 forks source link

Issue with use submitted groups and drivers module #118

Closed andrewelamb closed 5 years ago

andrewelamb commented 5 years ago

The Drivers module is currently incompatible with certain user submitted groups. I was unable to figure out the root cause. But the problem starts here:

build_filtered_mutation_df_per_group <- function(df,group_column,count_threshold){
df <- df %>% .[complete.cases(.),]

Using Alfredo's file the above df ends up empty. I added the below lines to return an empty df instead of triggering an error during the rest of the function:

######### needs to account for when this df has now rows ############################### if(nrow(df) == 0) return(df)

I also added the first line in this reactive.

scatter_plot_df <- reactive({ if (nrow(df_for_regression()) == 0) return(NULL) df_for_plot <- compute_driver_associations( df_for_regression(), response_var = input$response_variable, group_column = group_internal_choice(), group_options = get_unique_column_values( group_internal_choice(), subset_df())) %>% rename(label="combo",y="neglog_pval",x="effect_size") })

And finally:

validate( need(!is.null(scatter_plot_df()), "Group choices incompatible with mutation choice"))

So when the df is empty the above warning message is shown instead of the image. I relaize now this is a bad warning message since the user picks a response variable, not a mutation.

Two things need to happen:

  1. Pick a better warning.
  2. Figure out why the function gets an empty df after filtering for complete.cases.