Skip to contents

Draw TrackSOM network plot where each node represents a meta-cluster, coloured by the time-point it exists or median/mean marker values. Meta-clusters are connected with edges, indicating a transition over time.

Usage

DrawNetworkPlot(dat, timepoint.col, timepoints, cluster.col,
 marker.cols)

Arguments

dat

Data table. The dataset

timepoint.col

Column denoting the time point column

timepoints

Vector of time-points

cluster.col

Column denoting the TrackSOM meta-cluster ID

marker.cols

Columns denoting the markers to plot

calculation.type

The aggregation (mean/median) type for colouring the nodes

node.size

Whether the nodes are to be sized based on the proportion of cells it captured ('auto') or just constant (a number denoting the node size)

min.node.size

Smallest node size. Only used if node.size is 'auto'

max.node.size

Largest node size. Only used if node.size is 'auto'

arrow.length

Length of the arrow

arrow.head.gap

Gap between the node and the head of the arrow

standard.colours

Colour scheme for colouring the nodes. Can only be either one of the colours specified by the viridis package https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html or spectral, bupu, rdylbu.

img.height

Height of the image for network plot export

img.width

Width of the image for network plot export

load.temp.data

Whether to load some intermediate calculations or not. These intermediate files contain the details of each node and edge, and produced by the function after the very first run.

mapping

A data.table containing the annotation (cellular population) each meta-cluster in each time-point represents. The data.table must contain a column meta-cluster ID column named as per cluster.col, time-point column named as per timepoint.col, and a cell population column named as per population.col.

population.col

Column denoting the cell population name column. Only used if mapping is not NULL.

graph.layout

The layout of the network plot. Could be anything from the ggraph, graphlayouts, and igraph packages.

legend.position

Position of the legend, as per ggplot2.

no_merge

Whether meta-cluster merging was allowed. This only affect the network plot coloured by the meta-cluster origin. If merging was permitted, any merged meta-clusters will be coloured grey. If merging was not permitted, any split meta-clusters will be coloured the same as their parent.

file.format

Image export file format

line.width

Width of each edge

Examples


library(data.table)
data_files <- sapply(c(0:4), function(i) {
  system.file("extdata", paste0("synthetic_d", i, ".fcs"), package="TrackSOM")
})
use_cols <- c("x", "y", "z")
tracksom_result <- TrackSOM(inputFiles = data_files,
                            colsToUse = use_cols,
                            nClus = 10,
                            dataFileType = ".fcs"
)
#> Reading file /home/runner/work/_temp/Library/TrackSOM/extdata/synthetic_d0.fcs
#> Reading file /home/runner/work/_temp/Library/TrackSOM/extdata/synthetic_d1.fcs
#> Reading file /home/runner/work/_temp/Library/TrackSOM/extdata/synthetic_d2.fcs
#> Reading file /home/runner/work/_temp/Library/TrackSOM/extdata/synthetic_d3.fcs
#> Reading file /home/runner/work/_temp/Library/TrackSOM/extdata/synthetic_d4.fcs
#> Building SOM
#> Mapping data to SOM
#> Building MST
#> Extracting SOM nodes for each time point
#> Running meta clustering
#> Meta clustering time point 1 with 83 SOM nodes
#> Meta clustering time point 2 with 90 SOM nodes
#> Meta clustering time point 3 with 93 SOM nodes
#> Meta clustering time point 4 with 95 SOM nodes
#> Meta clustering time point 5 with 93 SOM nodes

data <- lapply(c(0:4), function(i) {
  fread(system.file("extdata", paste0("synthetic_d", i, ".csv"), package="TrackSOM"))
})
data <- rbindlist(data)
tracksom_res <- ConcatenateClusteringDetails(
  dat = data,
  tracksom.result = tracksom_result,
  timepoint.col = 'timepoint',
  timepoints = c("Mock", "SYN-1", "SYN-2", "SYN-3", "SYN-4")
)
DrawNetworkPlot(tracksom_res,
                'timepoint',
                c("Mock", "SYN-1", "SYN-2", "SYN-3", "SYN-4"),
                "TrackSOM_metacluster_lineage_tracking",
                use_cols)
#> Calculating edges
#> Computing node details
#> Calculating marker's average per node
#> Saving node and edge details
#> Start drawing plots
#> Warning: Existing variables `x` and `y` overwritten by layout variables
#> Drawing plots coloured by time point
#> Drawing plots coloured by origin
#> Drawing plots coloured by x
#> Drawing plots coloured by y
#> Drawing plots coloured by z