Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Mar 21, 2024
1 parent 3dec3fa commit d815fd0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export(plotKEGGPathway)
export(plotMAF)
export(plotPCA)
export(plotSNVInfo)
export(plotSNVSummary)
export(returnGenes)
export(reverseAnnot)
export(setAnnotation)
Expand Down
4 changes: 2 additions & 2 deletions R/plotKEGGPathway.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plotKEGGPathway <- function(stana, species, pathway_id,
only_ko=FALSE, summarize=FALSE, nudge_y=0,
point_mode=FALSE, sp_colors=NULL,
point_size=1){
sum_flag <- FALSE
sum_flag <- FALSE
if (is.null(sp_colors)) {
## Assign random colors
sp_colors <- scales::brewer_pal(palette="RdBu")(length(species)) |>
Expand Down Expand Up @@ -91,7 +91,7 @@ plotKEGGPathway <- function(stana, species, pathway_id,
lfcs[[sp]] <- apply(ko_tbl, 1, sum)
} else {
qqcat("@{sp}: @{names(cl)[1]} / @{names(cl)[2]}\n")
lfcs[[sp]] <- lL2FC(ko_tbl, cl[[1]], cl[[2]])
lfcs[[sp]] <- L2FC(ko_tbl, cl[[1]], cl[[2]], method="mod.t")
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,24 @@ plotSNVInfo <- function(stana, sp) {
xlab("major_allele/minor_allele")+
cowplot::theme_cowplot()+
ggtitle(title)
}

#' plotSNVSummary
#' @param stana stana object
#' @param sp species_id
#' @param param parameter to plot
#' @export
#' @return ggplot object
plotSNVSummary <- function(stana, sp, param="mean_coverage") {
df <- stana@snpsSummary
if (dim(df)[1]==0) {stop("SNV summary not available")}
df <- df %>% dplyr::filter(species_id == sp)
if (length(stana@cl)!=0) {
df[["group"]] <- listToNV(stana@cl)[df$sample_name]
ggplot(df, aes(x=group, y=.data[[param]])) +
geom_boxplot() + cowplot::theme_cowplot()
} else {
ggplot(df, aes(y=.data[[param]])) +
geom_boxplot() + cowplot::theme_cowplot()
}
}
21 changes: 21 additions & 0 deletions man/plotSNVSummary.Rd

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

0 comments on commit d815fd0

Please sign in to comment.