Skip to content

Commit

Permalink
Merge pull request #148 from DendrouLab/sarah_issue46
Browse files Browse the repository at this point in the history
Fixes #46
  • Loading branch information
bio-la authored Jan 8, 2024
2 parents 7c23e59 + 85445bc commit 4d94536
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Releases

### fixed

- fixed error in `vis`
- error occurred when only wanting to plot continuous or categorical variables (or neither), not both

### dependencies

## v0.4.1
Expand Down
13 changes: 8 additions & 5 deletions panpipes/R_scripts/plot_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ parse_cell_metadata <- function(cmtd, cat_vars, grp_vars){
parse_vars <- function(cat_vars){
if (is.list(cat_vars)){
uniq_cat_vars <- unique(unlist(cat_vars))
uniq_cat_vars
# cat vars
if (!is.null(uniq_cat_vars)){
cat_split = data.frame(str_split(uniq_cat_vars, ":", simplify = T)) %>%
mutate(mod =ifelse(X1 %in% c('rna', 'prot', 'atac', 'rep'), X1, "multimodal"),
variable = gsub(":", "_", uniq_cat_vars)) %>%
select(mod, variable)
}
else{
cat_split = NULL
}
}else{
cat_split = data.frame(variable=gsub(":", "_", cat_vars))
}
Expand Down Expand Up @@ -87,7 +90,7 @@ cmtd <- parse_cell_metadata(cmtd, cat_vars, grp_vars)


# Barplots ----------------------------------------------------------------
if( PARAMS$do_plots$categorical_barplots){
if( PARAMS$do_plots$categorical_barplots & !is.null(cat_vars)){
for( mod in unique(cat_vars$mod)){
if (!dir.exists(file.path(mod))) dir.create(file.path(mod))
print(mod)
Expand Down Expand Up @@ -123,7 +126,7 @@ if( PARAMS$do_plots$categorical_barplots){
}
}
# Stacked barplots by grouping var ----------------------------------------------------------------
if( PARAMS$do_plots$categorical_stacked_barplots){
if( PARAMS$do_plots$categorical_stacked_barplots & !is.null(cat_vars) & !is.null(grp_vars)){

for( mod in unique(cat_vars$mod)){
print(mod)
Expand Down Expand Up @@ -179,7 +182,7 @@ if( PARAMS$do_plots$categorical_stacked_barplots){
}

# Violin by grouping var ----------------------------------------------------------------
if( PARAMS$do_plots$continuous_violin){
if( PARAMS$do_plots$continuous_violin & !is.null(cont_vars) & !is.null(grp_vars)){


for( mod in unique(cont_vars$mod)){
Expand Down

0 comments on commit 4d94536

Please sign in to comment.