Skip to contents

Given a TrackSOM clustering and tracking, descramble the meta-cluster ID. Handy to work out the meta-cluster transitions.

Usage

GetTransitionsAsEdges(dat, timepoints, timepoint_col, cluster_col)

Arguments

dat

Data.table storing the clustered gated dataset

timepoints

Vector containing the time points in order

timepoint_col

Character Column denoting time points in dat

cluster_col

Character Column denoting cluster id produced by tracking by lineage determination in dat

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")
)
GetTransitionsAsEdges(dat = tracksom_res,
                      timepoint_col = 'timepoint',
                      timepoints = c("Mock", "SYN-1", "SYN-2", "SYN-3", "SYN-4"),
                      cluster_col = "TrackSOM_metacluster_lineage_tracking")
#>                                           from
#> 1                                          1_C
#> 2                                          1_J
#> 3                                          1_G
#> 4                                          1_B
#> 5                                          1_A
#> 6                                          1_G
#> 7                                          1_B
#> 8                                          1_E
#> 9                                          1_D
#> 10                                         1_E
#> 11                                         1_H
#> 12                                         1_F
#> 13                                         1_C
#> 14                                         1_E
#> 15                                         1_H
#> 16                                         1_G
#> 17                                     2_(D,E)
#> 18                                       2_E|1
#> 19                                       2_E|1
#> 20                                 2_(G|2,H|1)
#> 21                               2_(A,B|1,G|1)
#> 22                                       2_C|1
#> 23                                       2_C|1
#> 24                               2_(A,B|1,G|1)
#> 25                                     2_(B,G)
#> 26                                     2_(F,H)
#> 27                                         2_J
#> 28                                         2_J
#> 29                                     3_(D,E)
#> 30                                       3_E|1
#> 31                                       3_E|1
#> 32                                         3_K
#> 33                                         3_L
#> 34                                       3_J|1
#> 35                                       3_J|1
#> 36                     3_((A,B|1,G|1)|1,(B,G))
#> 37                         3_((A,B|1,G|1),C|1)
#> 38                                 3_((F,H),J)
#> 39                                         3_M
#> 40                         3_((A,B|1,G|1),C|1)
#> 41                                 3_(G|2,H|1)
#> 42                         3_((A,B|1,G|1),C|1)
#> 43                                 3_(G|2,H|1)
#> 44                                     4_(D,E)
#> 45                                       4_E|1
#> 46                                       4_E|1
#> 47 4_(((A,B|1,G|1),C|1),((A,B|1,G|1)|1,(B,G)))
#> 48                             4_(((F,H),J),M)
#> 49           4_(((A,B|1,G|1),C|1)|1,(G|2,H|1))
#> 50                       4_((A,B|1,G|1),C|1)|2
#> 51                               4_(G|2,H|1)|1
#> 52                             4_(((F,H),J),M)
#> 53                                       4_J|1
#> 54                                       4_J|1
#> 55           4_(((A,B|1,G|1),C|1)|1,(G|2,H|1))
#>                                             to
#> 1                                          2_C
#> 2                                          2_J
#> 3                                2_(A,B|1,G|1)
#> 4                                2_(A,B|1,G|1)
#> 5                                2_(A,B|1,G|1)
#> 6                                      2_(B,G)
#> 7                                      2_(B,G)
#> 8                                      2_(D,E)
#> 9                                      2_(D,E)
#> 10                                       2_E|1
#> 11                                     2_(F,H)
#> 12                                     2_(F,H)
#> 13                                       2_C|1
#> 14                                       2_E|2
#> 15                                 2_(G|2,H|1)
#> 16                                 2_(G|2,H|1)
#> 17                                     3_(D,E)
#> 18                                       3_E|1
#> 19                                       3_E|1
#> 20                                 3_(G|2,H|1)
#> 21                         3_((A,B|1,G|1),C|1)
#> 22                         3_((A,B|1,G|1),C|1)
#> 23                         3_((A,B|1,G|1),C|1)
#> 24                     3_((A,B|1,G|1)|1,(B,G))
#> 25                     3_((A,B|1,G|1)|1,(B,G))
#> 26                                 3_((F,H),J)
#> 27                                 3_((F,H),J)
#> 28                                       3_J|1
#> 29                                     4_(D,E)
#> 30                                       4_E|1
#> 31                                       4_E|1
#> 32                                         4_K
#> 33                                         4_L
#> 34                                       4_J|1
#> 35                                       4_J|1
#> 36 4_(((A,B|1,G|1),C|1),((A,B|1,G|1)|1,(B,G)))
#> 37 4_(((A,B|1,G|1),C|1),((A,B|1,G|1)|1,(B,G)))
#> 38                             4_(((F,H),J),M)
#> 39                             4_(((F,H),J),M)
#> 40           4_(((A,B|1,G|1),C|1)|1,(G|2,H|1))
#> 41           4_(((A,B|1,G|1),C|1)|1,(G|2,H|1))
#> 42                       4_((A,B|1,G|1),C|1)|2
#> 43                               4_(G|2,H|1)|1
#> 44                                     5_(D,E)
#> 45                                       5_E|1
#> 46                                       5_E|1
#> 47 5_(((A,B|1,G|1),C|1),((A,B|1,G|1)|1,(B,G)))
#> 48                             5_(((F,H),J),M)
#> 49           5_(((A,B|1,G|1),C|1)|1,(G|2,H|1))
#> 50                       5_((A,B|1,G|1),C|1)|2
#> 51                               5_(G|2,H|1)|1
#> 52                     5_((((F,H),J),M)|1,J|1)
#> 53                     5_((((F,H),J),M)|1,J|1)
#> 54                     5_((((F,H),J),M)|1,J|1)
#> 55         5_(((A,B|1,G|1),C|1)|1,(G|2,H|1))|1