Skip to content

Commit

Permalink
Minor fix for plot_loo
Browse files Browse the repository at this point in the history
added a warning when the filter removes all the taxa.
update webpage
  • Loading branch information
mchevalier2 committed Jun 10, 2024
1 parent 44c2e4e commit 4443eb0
Show file tree
Hide file tree
Showing 98 changed files with 249 additions and 244 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Imports:
clipr,
DBI,
Expand Down
6 changes: 5 additions & 1 deletion R/plot.diagram.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ plot_diagram <- function(x, bars=FALSE,

if (length(col) != ncol(x)-1) col = base::rep_len(col,ncol(x)-1)

cs <- apply(abs(x[, -1]), 2, max)
if(ncol(x) > 2) {
cs <- apply(abs(x[, -1]), 2, max)
} else {
cs <- max(abs(x[, 2]))
}
cs <- ifelse(cs > yax_incr, cs, yax_incr)
cs <- c(0, 0, cumsum(cs + sum(cs)*0.01 ) )# Adding 1% of the total space to each row

Expand Down
26 changes: 15 additions & 11 deletions R/plot.loo.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,21 @@ plot_loo <- function( x, optima=TRUE,
df <- df[, c(1, order(apply(df[, -1], 2, function(x) mean(x[abs(x)>0])), decreasing = ifelse(sort=='incr', FALSE, TRUE)) + 1)]
}

df <- df[, c(1, which(apply(df[, -1], 2, function(x) mean(abs(x)[abs(x)>0])) >= filter) + 1)]

plot_diagram(df, bars=TRUE,
save=save, filename=paste0(strsplit(filename, ifelse(as.png, '.png', '.pdf'))[[1]],'_',clim,ifelse(as.png, '.png', '.pdf')),
width=width, height=height, as.png=as.png, png.res=png.res,
yax_incr=yax_incr2, bar_width=bar_width2, xlim=xlim,
tickAtSample=tickAtSample,
col_pos=col_pos[clim], col_neg=col_neg[clim],
title=title2, src='loo')

rs[[clim]] <- sort(unlist(lapply(x$reconstructions[[clim]]$loo, function(x) return(mean(x[abs(x)>0])))))
w <- which(apply(df[, -1], 2, function(x) mean(abs(x)[abs(x)>0])) >= filter)
if(length(w) == 0) {
warning("No taxa remain after filtering. Adjust the filter value to include more taxa.")
} else {
df <- df[, c(1, w + 1)]
plot_diagram(df, bars=TRUE,
save=save, filename=paste0(strsplit(filename, ifelse(as.png, '.png', '.pdf'))[[1]],'_',clim,ifelse(as.png, '.png', '.pdf')),
width=width, height=height, as.png=as.png, png.res=png.res,
yax_incr=yax_incr2, bar_width=bar_width2, xlim=xlim,
tickAtSample=tickAtSample,
col_pos=col_pos[clim], col_neg=col_neg[clim],
title=title2, src='loo')

rs[[clim]] <- sort(unlist(lapply(x$reconstructions[[clim]]$loo, function(y) if(!unique(as.vector(is.na(y)))){return(mean(y[, var_to_plot][abs(y[, var_to_plot])>0]))})))
}
}
return(invisible(rs))

Expand Down
Binary file modified crestr_1.3.1.9000.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/articles/calibration-data.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4443eb0

Please sign in to comment.