Data visualization


All examples in this section will be done with the the aCML dataset as reference.

Summary report for a dataset and boolean queries{#sec:view}

We use the function view to get a short summary of a dataset that we loaded in TRONCO; this function reports on the number of samples and events, plus some meta information that could be displayed graphically.


Creating views with the as functions

Several functions are available to create views over a dataset, with a set of parameter which can constraint the view -- as in the SELECT/JOIN approaches in databases. In the following examples we show their execution with the default parameters, but shorten their output to make this document readable.

The main as functions are here documented. as.genotypes, that we can use to get the matrix of genotypes that we imported.


Differently, and, that show tables with the events that we are processing in all dataset or in a specific sample that we want to examine.[1:5, ], sample = 'patient 2')

Concerning genes, as.genes shows the mnemonic names of the genes (or chromosomes, cytobands, etc.) that we included in our dataset.


And as.types shows the types of alterations (e.g., mutations, amplifications, etc.) that we have find in our dataset, and function as.colors shows the list of the colors which are associated to each type.


A function as.gene can be used to display the alterations of a specific gene across the samples

head(as.gene(aCML, genes='SETBP1'))

Views over samples can be created as well. as.samples and which.samples list all the samples in the data, or return a list of samples that harbour a certain alteration. The former is


and the latter is

which.samples(aCML, gene='TET2', type='Nonsense point')

A slightly different function, which manipulates the data, is as.alterations, which transforms a dataset with events of different type to events of a unique type, labeled Alteration.

dataset = as.alterations(aCML)

When samples are enriched with stage information function as.stages can be used to create a view over such table. Views over patterns can be created as well -- see Model Inference with CAPRI.

Dataset size

A set of functions allow to get the number of genes, events, samples, types and patterns in a dataset.



Oncoprints are the most effective data-visualization functions in TRONCO. These are heatmaps where rows represent variants, and columns samples (the reverse of the input format required by TRONCO), and are annotated and displayed/sorted to enhance which samples have which mutations etc.

By default oncoprint will try to sort samples and events to enhance exclusivity patterns among the events.


But the sorting mechanism is bypassed if one wants to cluster samples or events, or if one wants to split samples by cluster (not shown). In the clustering case, the ordering is given by the dendrograms. In this case we also show the annotation of some groups of events via parameter gene.annot.

    legend = FALSE, 
    samples.cluster = TRUE, 
    gene.annot = list(one = list('NRAS', 'SETBP1'), two = list('EZH2', 'TET2')),
    gene.annot.color = 'Set2',
    genes.cluster = TRUE)

Oncoprints can be annotated; a special type of annotation is given by stage data. As this is not available for the aCML dataset, we create it randomly, just for the sake of showing how the oncoprint is enriched with this information. This is the random stage map that we create -- if some samples had no stage a NA would be added automatically.

stages = c(rep('stage 1', 32), rep('stage 2', 32))
stages = as.matrix(stages)
rownames(stages) = as.samples(aCML)
dataset = annotate.stages(aCML, stages = stages)

The as.stages function can now be used to create a view over stages.


After that the data is annotated via annotate.stages function, we can again plot an oncoprint -- which this time will detect that the dataset has also stages associated, and will diplay those

oncoprint(dataset, legend = FALSE)

If one is willing to display samples grouped according to some variable, for instance after a sample clustering task, he can use group.samples parameter of oncoprint and that will override the mutual exclusivity ordering. Here, we make the trick of using the stages as if they were such clustering result.

```r output for aCML data with randomly annotated stages, in left, and samples clustered by group assignment in right -- for simplicity the group variable is again the stage annotation."} oncoprint(dataset, group.samples = as.stages(dataset))

## Groups visualization (e.g., pathways)

TRONCO provides functions to visualize groups of events, which in this case are called pathways -- though this could be any group that one would like to define. Aggregation happens with the same rational as the `as.alterations` function, namely by merging the events in the group.

We make an example of a pathway called *MyPATHWAY* involving genes SETBP1, EZH2 and WT1; we want it to be colored in red, and we want to have the genotype of each event to be maintened in the dataset. We proceed as follows  (R's output is omitted).

pathway = as.pathway(aCML,
    pathway.genes = c('SETBP1', 'EZH2', 'WT1'), = 'MyPATHWAY',
    pathway.color = 'red',
    aggregate.pathway = FALSE)

Which we then visualize with an oncoprint

oncoprint(pathway, title = 'Custom pathway',  font.row = 8, cellheight = 15, cellwidth = 4)

In TRONCO there is also a function which creates the pathway view and the corresponding oncoprint to multiple pathways, when these are given as a list. We make here a simple example of two custom pathways.

    pathways=list(P1 = c('TET2', 'IRAK4'),  P2=c('SETBP1', 'KIT')),        
    font.row = 8)

If we had to visualize just the signature of the pathway, we could set aggregate.pathways=T.

    pathways=list(P1 = c('TET2', 'IRAK4'),  P2=c('SETBP1', 'KIT')),
    aggregate.pathways = TRUE,
    font.row = 8)

The same operation could have been done using WikiPathways. We can query WikiPathways and collect HGNC gene symbols and titles for pathways of interest as follows. (R's output is omitted).

# quotes inside query to require both terms
my.pathways <- findPathwaysByText('SETBP1 EZH2 TET2 IRAK4 SETBP1 KIT')
human.filter <- lapply(my.pathways, function(x) x$species == "Homo sapiens")
my.hs.pathways <- my.pathways[unlist(human.filter)] 
# collect pathways idenifiers
my.wpids <- sapply(my.hs.pathways, function(x) x$id)


Now pw.genes and pw.title can be used as input for the function as.pathway. It is also possible to view and edit these pathways at WikiPathways using the following commands to open tabs in your default browser.


Try the TRONCO package in your browser

Any scripts or data that you put into this service are public.

TRONCO documentation built on Nov. 8, 2020, 5:51 p.m.