Skip to content

Commit

Permalink
Restrict available phenotypes to those for which we have all requisit…
Browse files Browse the repository at this point in the history
…e columns, rather than giving an error for missing columns.
  • Loading branch information
AB-Kent committed Jun 17, 2019
1 parent 02debfb commit 2656ba5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions inst/spatial_map_viewer_app/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ source(file.path(base_dir, 'phenotype_color_module.R'))
# .export_path = 'C:\\Research\\phenoptrExamplesData\\DemoSlides\\export'

csd = readr::read_csv(.nn_path, na='#N/A', col_types=readr::cols())

# The available phenotypes are ones for which we have both
# phenotype and Cell ID <phenotypes> columns.
# We don't use the Distance to <phenotype> columns and we don't support
# multiple phenotypes.
available_phenotypes = names(csd) %>%
stringr::str_subset('Phenotype ') %>%
stringr::str_remove('Phenotype ')

# Check that we have distance and Cell ID columns for all phenotypes
required_columns = c(paste0('Distance to ', available_phenotypes, '+'),
paste0('Cell ID ', available_phenotypes, '+'))
missing_columns = setdiff(required_columns, names(csd))
if (length(missing_columns) > 0)
stop('Some required columns are not available: ',
paste(missing_columns, collapse=', '))
distance_to_phenotypes = names(csd) %>%
stringr::str_subset('Distance to ') %>%
stringr::str_remove('Distance to ') %>%
stringr::str_remove('\\+$')

available_phenotypes = intersect(available_phenotypes, distance_to_phenotypes)

available_fields = sort(unique(csd[[phenoptr::field_column(csd)]]))

0 comments on commit 2656ba5

Please sign in to comment.