Skip to content

Instantly share code, notes, and snippets.

@hammer
Last active January 9, 2017 21:19
Show Gist options
  • Save hammer/056ae316e870b5c771b12e482bfa921b to your computer and use it in GitHub Desktop.
Save hammer/056ae316e870b5c771b12e482bfa921b to your computer and use it in GitHub Desktop.
Exploring COSMIC signatures
# deconstructSigs signatures.cosmic
library("deconstructSigs")
library("tibble")
signatures.cosmic.tidy <- tibble::rownames_to_column(as.data.frame(t(signatures.cosmic)))
# COSMIC http://cancer.sanger.ac.uk/cancergenome/assets/signatures_probabilities.txt
cosmic.current <- read.delim("http://cancer.sanger.ac.uk/cancergenome/assets/signatures_probabilities.txt", check.names = F)
cosmic.current.clean <- cosmic.current[ , colnames(cosmic.current) != ""]
cosmic.current.tidy <- cosmic.current.clean[,names(cosmic.current.clean) not in c("Substitution Type","Trinucleotide")]
# Compare
both.tidy <- dplyr::left_join(signatures.cosmic.tidy, cosmic.current.tidy, by = c("rowname" = "Somatic Mutation Type"))
both.tidy[,paste("Signature", c(1:30), sep=".")] - both.tidy[,paste("Signature", c(1:30))]
# Visualization
heatmap.2(as.matrix(signatures.cosmic),dendrogram='none', Rowv=FALSE, Colv=FALSE,trace='none')
# Signature similarities
heatmap.2(cosine(t(as.matrix(signatures.cosmic))), trace='none')
similar.sigs <- which(cosine(t(as.matrix(signatures.cosmic))) > 0.9, arr.in=TRUE) # 5 + 16 and 12 + 26 look quite similar; 26 is believed to be associated with defective DNA mismatch repair
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment