Skip to content

Commit

Permalink
docs: add CCCPlot and ClonalX plots to README and mention scRepertoir…
Browse files Browse the repository at this point in the history
…e in the Credits in README
  • Loading branch information
pwwang committed Oct 17, 2024
1 parent e6ba44b commit 1ac800d
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ importFrom(plotthis,LollipopPlot)
importFrom(plotthis,Network)
importFrom(plotthis,PieChart)
importFrom(plotthis,PrepareEnrichrResult)
importFrom(plotthis,RadarPlot)
importFrom(plotthis,RarefactionPlot)
importFrom(plotthis,RidgePlot)
importFrom(plotthis,RingPlot)
importFrom(plotthis,SankeyPlot)
importFrom(plotthis,ScatterPlot)
importFrom(plotthis,SpiderPlot)
importFrom(plotthis,TrendPlot)
importFrom(plotthis,UpsetPlot)
importFrom(plotthis,VennDiagram)
Expand Down
20 changes: 14 additions & 6 deletions R/cccplot.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#' Cell-Cell Communication Plot
#'
#' @description Plot the cell-cell communication.
#' See also the review: https://www.sciencedirect.com/science/article/pii/S2452310021000081
#' the LIANA package: https://liana-py.readthedocs.io/en/latest/notebooks/basic_usage.html#Tileplot
#' and the CCPlotR package: https://github.com/Sarah145/CCPlotR
#' See also:
#' * The review: \url{https://www.sciencedirect.com/science/article/pii/S2452310021000081}
#' * The LIANA package: \url{https://liana-py.readthedocs.io/en/latest/notebooks/basic_usage.html#Tileplot}
#' * The CCPlotR package: \url{https://github.com/Sarah145/CCPlotR}
#'
#' @param data A data frame with the cell-cell communication data.
#' A typical data frame should have the following columns:
Expand All @@ -28,6 +29,11 @@
#' * sankey: A sankey plot with the source and target cells as the nodes and the communication as the flows.
#' * alluvial: Alias of "sankey".
#' * dot: A dot plot with the source and target cells as the nodes and the communication as the dots.
#' @param method The method to determine the plot entities.
#' * aggregation: Aggregate the ligand-receptor pairs interactions for each source-target pair.
#' Only the source / target pairs will be plotted.
#' * interaction: Plot the ligand-receptor pairs interactions directly.
#' The ligand-receptor pairs will also be plotted.
#' @param magnitude The column name in the data to use as the magnitude of the communication.
#' By default, the second last column will be used.
#' See `li.mt.show_methods()` for the available methods in `LIANA`.
Expand Down Expand Up @@ -71,8 +77,10 @@
#' @examples
#' set.seed(8525)
#' data(cellphonedb_res)
#' CCCPlot(data = cellphonedb_res)
#' CCCPlot(data = cellphonedb_res, plot_type = "network", legend.position = "none",
#' theme = "theme_blank", theme_args = list(add_coord = FALSE))
#' CCCPlot(cellphonedb_res, plot_type = "chord")
#' CCCPlot(cellphonedb_res, plot_type = "heatmap")
#' CCCPlot(cellphonedb_res, plot_type = "dot", weighted = FALSE)
#'
#' cellphonedb_res_sub <- cellphonedb_res[
Expand Down Expand Up @@ -158,7 +166,7 @@ CCCPlot <- function(
if (plot_type == "network") {
Network(links, from = source_col, to = target_col, node_fill_by = "name",
link_curvature = link_curvature, link_weight_name = link_weight_name, link_alpha = link_alpha,
node_fill_name = "Entities", link_weight_by = "interactionStrength", ...)
node_fill_name = "Source/Target", link_weight_by = "interactionStrength", ...)
} else if (plot_type %in% c("chord", "circos")) {
ChordPlot(links, y = "interactionStrength", from = source_col, to = target_col,
...)
Expand Down Expand Up @@ -204,7 +212,7 @@ CCCPlot <- function(
} else if (plot_type == "heatmap") {
data$ligand_receptor <- paste0(data[[ligand_col]], " -> ", data[[receptor_col]])
all_lrs <- unique(data$ligand_receptor)
data <- pivot_wider(data, names_from = ligand_receptor, values_from = magnitude,
data <- pivot_wider(data, names_from = "ligand_receptor", values_from = magnitude,
values_fill = 0)
Heatmap(data, rows = all_lrs, rows_name = "Ligand -> Receptor",
name = magnitude, columns_by = target_col, columns_split_by = source_col,
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ $ conda install pwwang::r-scplotter

## Credits

`scplotter` is greatly inspired by the [`SCP`][2] package, where the visualization was detached from the analysis and implemented in the [`plotthis`][1] package. The `scplotter` package is built upon the `plotthis` package and provides a set of even higher-level functions to visualize single-cell sequencing data.
`scplotter` draws significant inspiration from the [`SCP`][2] package, which separates visualization from analysis and implements it in the [`plotthis`][1] package. Building on `plotthis`, `scplotter` offers advanced functions for visualizing single-cell sequencing data. Special thanks to the [`scRepertoire`][2] package for its APIs that facilitate the analysis of single-cell TCR/BCR sequencing data.

## Gallery

### scRNA-seq

[`CellDimPlot`][3]

![CellDimPlot](./man/figures/celldimplot.png)
Expand Down Expand Up @@ -46,6 +48,20 @@ $ conda install pwwang::r-scplotter

![VolcanoPlot](./man/figures/volcanoplot.png)

[`CCCPlot`][10]

![CCCPlot](./man/figures/cccplot.png)

### scTCR-seq/scBCR-seq

[`ClonalVolumePlot`][11] | [`ClonalAbundancePlot`][12] | [`ClonalResidencyPlot`][13] | [`ClonalCompositionPlot`][14] | [`ClonalOverlapPlot`][15] | [`ClonalGeneUsagePlot`][16]

![clonalstat](./man/figures/clonalstat.png)

[`ClonalRarefactionPlot`][17] | [`ClonalGeneUsagePlot`][18] | [`ClonalDiversityPlot`][19] | [`ClonalPositionalPlot`][20]

![clonaldiv](./man/figures/clonaldiv.png)

[1]: https://github.com/pwwang/plotthis
[2]: https://zhanghao-njmu.github.io/SCP/index.html
[3]: https://pwwang.github.io/scplotter/reference/CellDimPlot.html
Expand All @@ -55,3 +71,14 @@ $ conda install pwwang::r-scplotter
[7]: https://pwwang.github.io/scplotter/reference/EnrichmentPlot.html
[8]: https://pwwang.github.io/plotthis/reference/gsea.html
[9]: https://pwwang.github.io/plotthis/reference/VolcanoPlot.html
[10]: https://pwwang.github.io/plotthis/reference/CCCPlot.html
[11]: https://pwwang.github.io/scplotter/reference/ClonalVolumePlot.html
[12]: https://pwwang.github.io/scplotter/reference/ClonalAbundancePlot.html
[13]: https://pwwang.github.io/scplotter/reference/ClonalResidencyPlot.html
[14]: https://pwwang.github.io/scplotter/reference/ClonalCompositionPlot.html
[15]: https://pwwang.github.io/scplotter/reference/ClonalOverlapPlot.html
[16]: https://pwwang.github.io/scplotter/reference/ClonalGeneUsagePlot.html
[17]: https://pwwang.github.io/scplotter/reference/ClonalRarefactionPlot.html
[18]: https://pwwang.github.io/scplotter/reference/ClonalGeneUsagePlot.html
[19]: https://pwwang.github.io/scplotter/reference/ClonalDiversityPlot.html
[20]: https://pwwang.github.io/scplotter/reference/ClonalPositionalPlot.html
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ reference:
- ClustreePlot
- EnrichmentPlot
- FeatureStatPlot
- CCCPlot
- title: scTCR-seq/scBCR-seq
desc: Functions for plotting single cell TCR-seq/BCR-seq data
contents:
Expand All @@ -30,6 +31,7 @@ reference:
contents:
- ifnb_sub
- pancreas_sub
- cellphonedb_res
- title: Re-exports
desc: Functions that are re-exported from plotthis
contents:
Expand Down
21 changes: 17 additions & 4 deletions man/CCCPlot.Rd

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

Binary file added man/figures/cccplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/clonaldiv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/clonalstat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1ac800d

Please sign in to comment.