Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored function names in R/plotting.R #63

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export(DownloadAssemblySummary)
export(GCA2lin)
export(GenContextNetwork)
export(IPG2Lineage)
export(LineagePlot)
export(RepresentativeAccNums)
export(acc2FA)
export(acc2Lineage)
Expand Down Expand Up @@ -37,6 +36,8 @@ export(convert_fa2tre)
export(count_bycol)
export(count_to_sunburst)
export(count_to_treemap)
export(createWordCloud2Element)
export(createWordCloudElement)
export(create_all_col_params)
export(create_lineage_lookup)
export(create_one_col_params)
Expand All @@ -60,17 +61,20 @@ export(get_proc_medians)
export(get_proc_weights)
export(ipr2viz)
export(ipr2viz_web)
export(lineage.DA.plot)
export(lineage.Query.plot)
export(lineage.domain_repeats.plot)
export(lineage.neighbors.plot)
export(lineage_sunburst)
export(make_job_results_url)
export(make_opts2procs)
export(mapAcc2Name)
export(map_acc2name)
export(map_advanced_opts2procs)
export(msa_pdf)
export(plotLineageDA)
export(plotLineageDomainRepeats)
export(plotLineageHeatmap)
export(plotLineageNeighbors)
export(plotLineageQuery)
export(plotLineageSunburst)
export(plotStackedLineage)
export(plotUpSet)
export(plot_estimated_walltimes)
export(prot2tax)
export(prot2tax_old)
Expand All @@ -86,9 +90,8 @@ export(run_deltablast)
export(run_rpsblast)
export(selectLongestDuplicate)
export(send_job_status_email)
export(shorten_lineage)
export(shortenLineage)
export(sinkReset)
export(stacked_lin_plot)
export(summ.DA)
export(summ.DA.byLin)
export(summ.GC)
Expand All @@ -98,10 +101,7 @@ export(summarize_bylin)
export(theme_genes2)
export(to_titlecase)
export(total_counts)
export(upset.plot)
export(wordcloud2_element)
export(wordcloud3)
export(wordcloud_element)
export(write.MsaAAMultipleAlignment)
export(write_proc_medians_table)
export(write_proc_medians_yml)
Expand Down
64 changes: 32 additions & 32 deletions R/plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#'
#' @examples
#' \dontrun{
#' shorten_lineage()
#' shortenLineage()
#' }
shorten_lineage <- function(data, colname = "Lineage", abr_len = 1) {
shortenLineage <- function(data, colname = "Lineage", abr_len = 1) {
abbrv <- function(x) {
pos_gt <- str_locate(x, ">")
pos_gt <- pos_gt[1]
Expand Down Expand Up @@ -94,9 +94,9 @@ shorten_lineage <- function(data, colname = "Lineage", abr_len = 1) {
#'
#' @examples
#' \dontrun{
#' upset.plot(pspa.sub, 10, "da2doms")
#' plotUpSet(pspa.sub, 10, "da2doms")
#' }
upset.plot <- function(query_data = "toast_rack.sub",
plotUpSet <- function(query_data = "toast_rack.sub",
colname = "DomArch", cutoff = 90,
RowsCutoff = FALSE, text.scale = 1.5,
point.size = 2.2, line.size = 0.8) {
Expand Down Expand Up @@ -259,9 +259,9 @@ upset.plot <- function(query_data = "toast_rack.sub",
#'
#' @examples
#' \dontrun{
#' lineage.DA.plot(toast_rack_data, 10, "DomArch.norep", "da2doms")
#' plotLineageDA(toast_rack_data, 10, "DomArch.norep", "da2doms")
#' }
lineage.DA.plot <- function(query_data = "prot",
plotLineageDA <- function(query_data = "prot",
colname = "DomArch",
cutoff = 90,
RowsCutoff = FALSE,
Expand All @@ -271,7 +271,7 @@ lineage.DA.plot <- function(query_data = "prot",
# @param type Character. Default is "da2doms" for Domain Architectures.
# Other alternative: "gc2da" for Genomic Contexts. -- unused parameter

query_data <- shorten_lineage(query_data, "Lineage", abr_len = 1)
query_data <- shortenLineage(query_data, "Lineage", abr_len = 1)

query.summ.byLin <- query_data %>% total_counts(cutoff = cutoff, column = colname, RowsCutoff = RowsCutoff)

Expand Down Expand Up @@ -355,9 +355,9 @@ lineage.DA.plot <- function(query_data = "prot",
#'
#' @examples
#' \dontrun{
#' lineage.Query.plot(prot, c("PspA", "PspB", "PspC", "PspM", "PspN"), 95)
#' plotLineageQuery(prot, c("PspA", "PspB", "PspC", "PspM", "PspN"), 95)
#' }
lineage.Query.plot <- function(query_data = all,
plotLineageQuery <- function(query_data = all,
queries,
colname = "ClustName",
cutoff, color = "default") {
Expand Down Expand Up @@ -394,7 +394,7 @@ lineage.Query.plot <- function(query_data = all,
# query_data contains all rows that possess a lineage
query_data <- query_data %>% filter(grepl("a", Lineage))

query_data <- shorten_lineage(query_data, "Lineage", abr_len = 1)
query_data <- shortenLineage(query_data, "Lineage", abr_len = 1)
query_lin_counts <- data.frame("Query" = character(0), "Lineage" = character(0), "count" = integer())
for (q in queries) {
query_lin <- query_by_lineage(data = query_data, query = q, column = {{ col }}, by = "Lineage")
Expand Down Expand Up @@ -492,10 +492,10 @@ lineage.Query.plot <- function(query_data = all,
#'
#' @examples
#' \dontrun{
#' lineage.neighbors.plot(pspa_data, pspa, "GenContext.norep", "da2doms")
#' plotLineageNeighbors(pspa_data, pspa, "GenContext.norep", "da2doms")
#' }
#'
lineage.neighbors.plot <- function(query_data = "prot", query = "pspa",
plotLineageNeighbors <- function(query_data = "prot", query = "pspa",
colname = "GenContext.norep") {
query_data <- query_data %>% filter(grepl("a", Lineage))
query.GCDA <- read_delim(paste0("Top-", query, "-neighbors.txt"),
Expand Down Expand Up @@ -567,9 +567,9 @@ lineage.neighbors.plot <- function(query_data = "prot", query = "pspa",
#'
#' @examples
#' \dontrun{
#' lineage.domain_repeats.plot()
#' plotLineageDomainRepeats()
#' }
lineage.domain_repeats.plot <- function(query_data, colname) {
plotLineageDomainRepeats <- function(query_data, colname) {
# query_data <- pspa_data
# colname <- "SIG.TM.LADB"

Expand Down Expand Up @@ -629,7 +629,7 @@ lineage.domain_repeats.plot <- function(query_data, colname) {
}


#' LineagePlot
#' plotLineageHeatmap
#'
#' @description
#' Generate a lineage plot
Expand All @@ -651,7 +651,7 @@ lineage.domain_repeats.plot <- function(query_data, colname) {
#'
#' @examples
#' \dontrun{
#' LineagePlot(psp_data,
#' plotLineageHeatmap(psp_data,
#' c(
#' "PspA", "Snf7", "Classical-AAA", "PspF", "PspB", "PspC", "ClgR", "PspM",
#' "Thioredoxin", "PspN_N", "DUF3046", "LiaI-LiaF-TM", "Toast_rack", "REC",
Expand All @@ -664,8 +664,8 @@ lineage.domain_repeats.plot <- function(query_data, colname) {
#' )
#' }
#'
LineagePlot <- function(prot, domains_of_interest, level = 3, label.size = 8) {
LevelReduction <- function(lin) {
plotLineageHeatmap <- function(prot, domains_of_interest, level = 3, label.size = 8) {
.LevelReduction <- function(lin) {
if (level == 1) {
gt_loc <- str_locate(lin, ">")[[1]]
if (is.na(gt_loc)) {
Expand Down Expand Up @@ -703,7 +703,7 @@ LineagePlot <- function(prot, domains_of_interest, level = 3, label.size = 8) {
all_grouped <- dplyr::union(all_grouped, domSub)
}

GetKingdom <- function(lin) {
.GetKingdom <- function(lin) {
gt_loc <- str_locate(lin, ">")[, "start"]

if (is.na(gt_loc)) {
Expand All @@ -715,12 +715,12 @@ LineagePlot <- function(prot, domains_of_interest, level = 3, label.size = 8) {
}
}

all_grouped <- all_grouped %>% mutate(ReducedLin = unlist(purrr::map(Lineage, LevelReduction)))
all_grouped <- all_grouped %>% mutate(ReducedLin = unlist(purrr::map(Lineage, .LevelReduction)))

all_grouped_reduced <- all_grouped %>%
group_by(Query, ReducedLin) %>%
summarize("count" = sum(count)) %>%
mutate(Kingdom = unlist(purrr::map(ReducedLin, GetKingdom)))
mutate(Kingdom = unlist(purrr::map(ReducedLin, .GetKingdom)))

lin_counts <- all_grouped_reduced %>%
group_by(Kingdom, ReducedLin) %>%
Expand Down Expand Up @@ -814,9 +814,9 @@ LineagePlot <- function(prot, domains_of_interest, level = 3, label.size = 8) {
#'
#' @examples
#' \dontrun{
#' stacked_lin_plot()
#' plotStackedLineage()
#' }
stacked_lin_plot <- function(prot, column = "DomArch", cutoff, Lineage_col = "Lineage",
plotStackedLineage <- function(prot, column = "DomArch", cutoff, Lineage_col = "Lineage",
xlabel = "Domain Architecture",
reduce_lineage = TRUE,
label.size = 8,
Expand All @@ -828,7 +828,7 @@ stacked_lin_plot <- function(prot, column = "DomArch", cutoff, Lineage_col = "Li
col <- sym(column)

if (reduce_lineage) {
prot <- shorten_lineage(prot, Lineage_col, abr_len = 3)
prot <- shortenLineage(prot, Lineage_col, abr_len = 3)
}

total_count <- total_counts(prot, column, cutoff, lineage_col = Lineage_col)
Expand Down Expand Up @@ -935,7 +935,7 @@ stacked_lin_plot <- function(prot, column = "DomArch", cutoff, Lineage_col = "Li
################
#### NEEDS SOME WORK

#' Wordcloud3
#' plotWordCloud3
#'
#' @param data
#' @param size
Expand Down Expand Up @@ -1048,9 +1048,9 @@ wordcloud3 <- function(data, size = 1, minSize = 0, gridSize = 0, fontFamily = "
#'
#' @examples
#' \dontrun{
#' wordcloud_element(prot, "da2doms", 10)
#' createWordCloudElement(prot, "da2doms", 10)
#' }
wordcloud_element <- function(query_data = "prot",
createWordCloudElement <- function(query_data = "prot",
colname = "DomArch",
cutoff = 70,
UsingRowsCutoff = FALSE) {
Expand Down Expand Up @@ -1125,9 +1125,9 @@ wordcloud_element <- function(query_data = "prot",
#'
#' @examples
#' \dontrun{
#' wordcloud_element(prot, "da2doms", 10)
#' createWordCloudElement(prot, "da2doms", 10)
#' }
wordcloud2_element <- function(query_data = "prot",
createWordCloud2Element <- function(query_data = "prot",
colname = "DomArch",
cutoff = 70,
UsingRowsCutoff = FALSE) {
Expand Down Expand Up @@ -1194,9 +1194,9 @@ wordcloud2_element <- function(query_data = "prot",
#'
#' @examples
#' \dontrun{
#' lineage_sunburst()
#' plotLineageSunburst()
#' }
lineage_sunburst <- function(prot, lineage_column = "Lineage",
plotLineageSunburst <- function(prot, lineage_column = "Lineage",
type = "sunburst",
levels = 2, colors = NULL, legendOrder = NULL, showLegend = TRUE, maxLevels = 5) {
lin_col <- sym(lineage_column)
Expand Down Expand Up @@ -1278,7 +1278,7 @@ lineage_sunburst <- function(prot, lineage_column = "Lineage",


## COMMENTED LINEAGE.DA.PLOT
# lineage.plot <- function(query_data, cutoff, type) {
# plotLineage <- function(query_data, cutoff, type) {
# switch(type,
# da2doms={wc <- DA.doms.wc; words <- toast_rack.DAdoms; colname <- "DomArch.norep"; toast_rack.summ.byLin <- toast_rack.DA.summ.byLin}, # elements <- toast_rack.DA;
# gc2da={wc <- GC.DA.wc; words <- toast_rack.GCDA; colname <- "GenContext.norep"; toast_rack.summ.byLin <- toast_rack.GC.summ.byLin} # elements <- toast_rack.GC;
Expand Down
8 changes: 4 additions & 4 deletions man/wordcloud2_element.Rd → man/createWordCloud2Element.Rd

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

8 changes: 4 additions & 4 deletions man/wordcloud_element.Rd → man/createWordCloudElement.Rd

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

8 changes: 4 additions & 4 deletions man/lineage.DA.plot.Rd → man/plotLineageDA.Rd

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

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

10 changes: 5 additions & 5 deletions man/LineagePlot.Rd → man/plotLineageHeatmap.Rd

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

Loading
Loading