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

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

Arguments

dat

Data table. The dataset

timepoints

Vector of time-points

timepoint.col

Column denoting the time point column

cluster.col

Column denoting the TrackSOM meta-cluster ID

marker.cols

Columns denoting the markers to plot

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.

plot.width

Width of the image for network plot export

plot.height

Height of the image for network plot export

font.size

Size of the font

file.format

Image export file format

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'

legend.position

Position of the legend, as per ggplot2.

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.

arrow.length

Length of the arrow

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.

cluster.ordering

A custom ordering for the meta-clusters (y-axis)

map.cluster.id

Whether to map the meta-cluster ID to numeric. Handy if the meta-cluster IDs get too long.

calculation.type

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

line.width

Width of each edge

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)

arrow.head.gap

Gap between the node and the head of the arrow

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.

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")
)
DrawTimeseriesHeatmap(dat = tracksom_res,
                      timepoint.col = 'timepoint',
                      timepoints = c("Mock", "SYN-1", "SYN-2", "SYN-3", "SYN-4"),
                      cluster.col = "TrackSOM_metacluster_lineage_tracking",
                      marker.cols = use_cols)
#> Computing node details
#> Computing edge details
#> Saving node and edge details
#> Drawing timeseries heatmap coloured by x
#> Drawing timeseries heatmap coloured by y
#> Drawing timeseries heatmap coloured by z