plot_cosine_heatmap: Plot cosine similarity heatmap

Description Usage Arguments Value See Also Examples

View source: R/plot_cosine_heatmap.R

Description

Plot pairwise cosine similarities in a heatmap.

Usage

1
2
plot_cosine_heatmap(cos_sim_matrix, col_order, cluster_rows = TRUE,
  method = "complete", plot_values = FALSE)

Arguments

cos_sim_matrix

Matrix with pairwise cosine similarities. Result from cos_sim_matrix

col_order

Character vector with the desired order of the columns names for plotting. Optional.

cluster_rows

Hierarchically cluster rows based on eucledian distance. Default = TRUE.

method

The agglomeration method to be used for hierarchical clustering. This should be one of "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC). Default = "complete".

plot_values

Plot cosine similarity values in heatmap. Default = FALSE.

Value

Heatmap with cosine similarities

See Also

mut_matrix, cos_sim_matrix, cluster_signatures

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## See the 'mut_matrix()' example for how we obtained the mutation matrix:
mut_mat <- readRDS(system.file("states/mut_mat_data.rds",
                    package="MutationalPatterns"))

## You can download the signatures from the COSMIC:
# http://cancer.sanger.ac.uk/cancergenome/assets/signatures_probabilities.txt

## We copied the file into our package for your convenience.
filename <- system.file("extdata/signatures_probabilities.txt",
                        package="MutationalPatterns")
cancer_signatures <- read.table(filename, sep = "\t", header = TRUE)

## Match the order to MutationalPatterns standard of mutation matrix
order = match(row.names(mut_mat), cancer_signatures$Somatic.Mutation.Type)
## Reorder cancer signatures dataframe
cancer_signatures = cancer_signatures[order,]
## Use trinucletiode changes names as row.names
## row.names(cancer_signatures) = cancer_signatures$Somatic.Mutation.Type
## Keep only 96 contributions of the signatures in matrix
cancer_signatures = as.matrix(cancer_signatures[,4:33])
## Rename signatures to number only
colnames(cancer_signatures) = as.character(1:30)

## Calculate the cosine similarity between each signature and each 96 mutational profile
cos_matrix = cos_sim_matrix(mut_mat, cancer_signatures)

## Cluster signatures based on cosine similarity 
sig_hclust = cluster_signatures(cancer_signatures)
col_order = colnames(cancer_signatures)[sig_hclust$order]

## Plot the cosine similarity between each signature and each sample with hierarchical 
## sample clustering and signatures order based on similarity

plot_cosine_heatmap(cos_matrix, col_order, cluster_rows = TRUE, method = "complete")

MutationalPatterns documentation built on May 3, 2018, 6 p.m.