Skip to content

Commit

Permalink
feat: include color palette in tx_type_palette
Browse files Browse the repository at this point in the history
  • Loading branch information
luciorq committed Nov 23, 2024
1 parent 334897c commit 4af2a6a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
23 changes: 21 additions & 2 deletions R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ plot_log2FC <- function(DEG_DET_table, selected_gene, custom_colors = NULL) {
)
) +
ggplot2::geom_bar(stat = "identity") +
ggplot2::scale_fill_manual(values = tx_type_color_names) +
ggplot2::scale_fill_manual(values = tx_type_palette()) +
ggplot2::theme_bw()
} else {
plot_obj <- ggplot2::ggplot(
Expand All @@ -301,9 +301,28 @@ plot_log2FC <- function(DEG_DET_table, selected_gene, custom_colors = NULL) {
)
) +
ggplot2::geom_bar(stat = "identity") +
ggplot2::scale_fill_manual(values = tx_type_color_names) +
ggplot2::scale_fill_manual(values = tx_type_palette()) +
ggplot2::theme_bw()
}
return(plot_obj)
# ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, vjust = 0.5))
}

tx_type_palette <- function() {
fixed_tx_biotypes <- c(
"gene", "protein_coding", "retained_intron",
"processed_transcript", "nonsense_mediated_decay",
"lncRNA", "processed_pseudogene",
"transcribed_unprocessed_pseudogene",
"unprocessed_pseudogene", "non_stop_decay", "transcribed_unitary_pseudogene",
"pseudogene", "unitary_pseudogene"
)
tx_type_color_names <- c(
"#fb8072", "#a6d854", "#8da0cb", "#fc8d62",
"#66c2a5", "#e78ac3", "#ffd92f", "#e5c494",
"#d9d9d9", "#d9d9d9", "#d9d9d9", "#ffffb3",
"#d9d9d9"
)
names(tx_type_color_names) <- fixed_tx_biotypes
return(tx_type_color_names)
}
4 changes: 2 additions & 2 deletions R/plot_tx_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ plot_tx_context <- function(
),
color = NA
) +
ggplot2::scale_fill_manual(values = tx_type_color_names) +
ggplot2::scale_color_manual(values = tx_type_color_names) +
ggplot2::scale_fill_manual(values = tx_type_palette()) +
ggplot2::scale_color_manual(values = tx_type_palette()) +
ggplot2::geom_segment(
mapping = ggplot2::aes(
x = segment_start,
Expand Down
2 changes: 1 addition & 1 deletion R/profile_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ plot_tx_expr <- function(genes_to_plot, profile_data) {
size = 3, shape = 21
) +
ggplot2::scale_alpha_manual(values = transparency_vector) +
ggplot2::scale_color_manual(values = tx_type_color_names, aesthetics = c("color", "fill")) +
ggplot2::scale_color_manual(values = tx_type_palette(), aesthetics = c("color", "fill")) +
# ggplot2::theme_bw()
ggpubr::theme_pubr() +
ggplot2::theme(legend.position = "right") +
Expand Down
3 changes: 2 additions & 1 deletion vignettes/isoformic_intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ This table will represent cases which could be characterized as isoform switches

Before we start plotting we will define a general set of colors to be used through the entire pipeline associated with a certain type of transcript. Here we colored all the most abundant types separately and the less abundant on the same grey tone and name that vector accordingly

```{r}
```{r, eval=FALSE}
# TODO: @luciorq Check implementation of function `tx_type_palette()`
fixed_tx_biotypes <- c(
"gene", "protein_coding", "retained_intron",
"processed_transcript", "nonsense_mediated_decay",
Expand Down

0 comments on commit 4af2a6a

Please sign in to comment.