Skip to content

Commit

Permalink
Enhancing variable names for color palettes.
Browse files Browse the repository at this point in the history
  • Loading branch information
enblacar committed Jul 21, 2024
1 parent 2f200c4 commit b3f3411
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
6 changes: 3 additions & 3 deletions vignettes/decoupleR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ information check `?decouple`.
```{r usage-decouple, message=TRUE}
res_decouple <- decoupleR::decouple(mat,
network,
.source='source',
.target='target',
.source ='source',
.target ='target',
minsize = 0)
res_decouple
```
Expand All @@ -292,7 +292,7 @@ Let us see the result for the consensus score in the previous `decouple` run:
```{r res_decouple, message=TRUE}
# Transform to matrix
mat_consensus <- res_decouple %>%
dplyr::filter(statistic=='consensus') %>%
dplyr::filter(statistic == 'consensus') %>%
decoupleR::pivot_wider_profile(id_cols = source,
names_from = condition,
values_from = score) %>%
Expand Down
17 changes: 11 additions & 6 deletions vignettes/pw_bk.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ counts <- data$counts %>%
~ dplyr::if_else(is.na(.x), 0, .x)) %>%
tibble::column_to_rownames(var = "gene") %>%
as.matrix()
head(counts)
```

Expand All @@ -97,6 +98,7 @@ deg <- data$limma_ttop %>%
dplyr::filter(!is.na(t)) %>%
tibble::column_to_rownames(var = "ID") %>%
as.matrix()
head(deg)
```

Expand Down Expand Up @@ -125,6 +127,7 @@ To access it we can use `decoupleR`:
```{r "progeny", message=FALSE}
net <- decoupleR::get_progeny(organism = 'human',
top = 500)
net
```

Expand Down Expand Up @@ -202,16 +205,17 @@ in activity between KO and WT:

```{r "barplot"}
# Plot
ends <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
colors <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
p <- ggplot2::ggplot(data = contrast_acts,
mapping = ggplot2::aes(x = stats::reorder(source, score),
y = score)) +
ggplot2::geom_bar(mapping = ggplot2::aes(fill = score),
color = "black",
stat = "identity") +
ggplot2::scale_fill_gradient2(low = ends[1],
ggplot2::scale_fill_gradient2(low = colors[1],
mid = "whitesmoke",
high = ends[2],
high = colors[2],
midpoint = 0) +
ggplot2::theme_minimal() +
ggplot2::theme(axis.title = element_text(face = "bold", size = 12),
Expand All @@ -224,6 +228,7 @@ p <- ggplot2::ggplot(data = contrast_acts,
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
ggplot2::xlab("Pathways")
p
```

Expand Down Expand Up @@ -255,7 +260,7 @@ df <- df %>%
dplyr::mutate(color = dplyr::if_else(weight < 0 & t_value > 0, '2', color)) %>%
dplyr::mutate(color = dplyr::if_else(weight < 0 & t_value < 0, '1', color))
ends <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
colors <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
p <- ggplot2::ggplot(data = df,
mapping = ggplot2::aes(x = weight,
Expand All @@ -264,15 +269,15 @@ p <- ggplot2::ggplot(data = df,
ggplot2::geom_point(size = 2.5,
color = "black") +
ggplot2::geom_point(size = 1.5) +
ggplot2::scale_colour_manual(values = c(ends[2], ends[1], "grey")) +
ggplot2::scale_colour_manual(values = c(colors[2], colors[1], "grey")) +
ggrepel::geom_label_repel(mapping = ggplot2::aes(label = ID)) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "none") +
ggplot2::geom_vline(xintercept = 0, linetype = 'dotted') +
ggplot2::geom_hline(yintercept = 0, linetype = 'dotted') +
ggplot2::ggtitle(pathway)
p
```

The pathway seems to be active since the majority of target genes with positive
Expand Down
4 changes: 2 additions & 2 deletions vignettes/pw_sc.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ p1 <- Seurat::DimPlot(data,
Seurat::NoLegend() +
ggplot2::ggtitle('Cell types')
ends <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
colors <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
p2 <- Seurat::FeaturePlot(data, features = c("Trail")) +
ggplot2::scale_colour_gradient2(low = ends[1], mid = 'white', high = ends[2]) +
ggplot2::scale_colour_gradient2(low = colors[1], mid = 'white', high = colors[2]) +
ggplot2::ggtitle('Trail activity')
p <- p1 | p2
Expand Down
10 changes: 5 additions & 5 deletions vignettes/tf_bk.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ tfs <- f_contrast_acts %>%
f_contrast_acts <- f_contrast_acts %>%
filter(source %in% tfs)
ends <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
colors <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
p <- ggplot2::ggplot(data = f_contrast_acts,
mapping = ggplot2::aes(x = stats::reorder(source, score),
y = score)) +
ggplot2::geom_bar(mapping = ggplot2::aes(fill = score),
color = "black",
stat = "identity") +
ggplot2::scale_fill_gradient2(low = ends[1],
ggplot2::scale_fill_gradient2(low = colors[1],
mid = "whitesmoke",
high = ends[2],
high = colors[2],
midpoint = 0) +
ggplot2::theme_minimal() +
ggplot2::theme(axis.title = element_text(face = "bold", size = 12),
Expand Down Expand Up @@ -277,7 +277,7 @@ df <- df %>%
dplyr::mutate(color = dplyr::if_else(mor < 0 & t_value > 0, '2', color)) %>%
dplyr::mutate(color = dplyr::if_else(mor < 0 & t_value < 0, '1', color))
ends <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
colors <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
p <- ggplot2::ggplot(data = df,
mapping = ggplot2::aes(x = logfc,
Expand All @@ -287,7 +287,7 @@ p <- ggplot2::ggplot(data = df,
ggplot2::geom_point(size = 2.5,
color = "black") +
ggplot2::geom_point(size = 1.5) +
ggplot2::scale_colour_manual(values = c(ends[2], ends[1], "grey")) +
ggplot2::scale_colour_manual(values = c(colors[2], colors[1], "grey")) +
ggrepel::geom_label_repel(mapping = ggplot2::aes(label = ID,
size = 1)) +
ggplot2::theme_minimal() +
Expand Down
4 changes: 2 additions & 2 deletions vignettes/tf_sc.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ p1 <- Seurat::DimPlot(data,
ggplot2::ggtitle('Cell types')
ends <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
colors <- rev(RColorBrewer::brewer.pal(n = 11, name = "RdBu")[c(2, 10)])
p2 <- Seurat::FeaturePlot(data, features = c("PAX5")) +
ggplot2::scale_colour_gradient2(low = ends[1], mid = 'white', high = ends[2]) +
ggplot2::scale_colour_gradient2(low = colors[1], mid = 'white', high = colors[2]) +
ggplot2::ggtitle('PAX5 activity')
Expand Down

0 comments on commit b3f3411

Please sign in to comment.