Example: NOTCH1-10
library(trackViewer)
d <- read.csv("NOTCH1-10.csv", header=TRUE)
df <- data.frame(d)
dim(df)
## [1] 96 11
head(df)
## ID segment chr start end type class VAF USMs S4
## 1 80 NOTCH1-10 9 139412301 139412400 NE intron 0.02128081 USM 7
## 2 81 NOTCH1-10 9 139412301 139412400 NE silent 0.01226590 NUSM 9
## 3 82 NOTCH1-10 9 139412301 139412400 NE silent 0.02441092 NUSM 11
## 4 83 NOTCH1-10 9 139412301 139412400 SE intron 0.01563667 USM 20
## 5 84 NOTCH1-10 9 139412301 139412400 NE missense 0.04596536 NUSM 27
## 6 85 NOTCH1-10 9 139412301 139412400 NE silent 0.02369065 USM 28
## mutations
## 1 9.139412393.G.A
## 2 9.139412322.C.G
## 3 9.139412376.G.A
## 4 9.139412392.G.A
## 5 9.139412381.G.T
## 6 9.139412382.G.A
#SNP <- df$mutations
SNP <- as.integer(substring(df$mutations, first = 3, last = 11))
SNP
## [1] 139412393 139412322 139412376 139412392 139412381 139412382 139412376
## [8] 139412399 139412382 139412381 139412375 139412331 139412302 139412394
## [15] 139412303 139412309 139412399 139412375 139412376 139412399 139412376
## [22] 139412381 139412376 139412375 139412376 139412324 139412391 139412381
## [29] 139412393 139412378 139412372 139412381 139412376 139412375 139412376
## [36] 139412324 139412391 139412381 139412393 139412378 139412372 139412375
## [43] 139412399 139412376 139412310 139412381 139412321 139412310 139412375
## [50] 139412372 139412332 139412380 139412340 139412375 139412376 139412376
## [57] 139412399 139412316 139412381 139412381 139412340 139412397 139412331
## [64] 139412326 139412381 139412393 139412382 139412372 139412375 139412375
## [71] 139412393 139412375 139412378 139412394 139412376 139412372 139412399
## [78] 139412375 139412400 139412373 139412389 139412332 139412375 139412315
## [85] 139412387 139412399 139412399 139412381 139412322 139412390 139412302
## [92] 139412319 139412319 139412386 139412389 139412376
VAF <- df$VAF *100
intVAF <- floor(VAF)
min(intVAF)
## [1] 0
max(intVAF)
## [1] 16
intVAF <- ifelse(intVAF>10,10,intVAF) # replacing values>10 with 10
min(intVAF)
## [1] 0
max(intVAF)
## [1] 10
class <- as.factor(df$class)
levels(class)
## [1] "intron" "missense" "missense_splice" "nonsense"
## [5] "silent" "splice" "splice_intron"
USMs <- as.factor(df$USMs)
levels(USMs)
## [1] "NUSM" "USM"
type <- as.factor(df$type)
levels(type)
## [1] "NE" "SE"
## Define GRange object
shortnames <- substring(SNP,first=7,last=9) # Last 3 digits of genomic coordinates
sample.gr <- GRanges("chr9",
IRanges(SNP, width=1, names=paste0("...",shortnames)))
## Features
features.gr <- GRanges("chr9",
IRanges(start=139412260, width=70, names="NOTCH1-9"),
fill="orange", height=0.025)
## Add score information
## Caution: values for score in lolliplot() needs to be an integer between 1 and 10
sample.gr$score <- intVAF
## Add color information
sample.gr$color <- as.integer(class)
## Use list to define legends. See ?grid::gpar to get more details.
keys <- list( labels=levels(class),
col=palette()[1:length(class)],
fill=palette()[1:length(class)])
## Add shape information
shapes <- c("square", "circle")
names(shapes) <- c("NUSM", "USM")
shapes
## NUSM USM
## "square" "circle"
sample.gr$shape <- shapes[as.integer(USMs)]
## Border and opacity
sample.gr$border <- "gray30"
## Caterpillar Layout
sample.gr$SNPsideID <- ifelse(type=="SE", "top", "bottom")
sample.gr
## GRanges object with 96 ranges and 5 metadata columns:
## seqnames ranges strand | score color shape
## <Rle> <IRanges> <Rle> | <numeric> <integer> <character>
## ...393 chr9 139412393 * | 2 1 circle
## ...322 chr9 139412322 * | 1 5 square
## ...376 chr9 139412376 * | 2 5 square
## ...392 chr9 139412392 * | 1 1 circle
## ...381 chr9 139412381 * | 4 2 square
## ... ... ... ... . ... ... ...
## ...319 chr9 139412319 * | 2 2 square
## ...319 chr9 139412319 * | 1 2 square
## ...386 chr9 139412386 * | 1 3 circle
## ...389 chr9 139412389 * | 1 2 circle
## ...376 chr9 139412376 * | 2 5 square
## border SNPsideID
## <character> <character>
## ...393 gray30 bottom
## ...322 gray30 bottom
## ...376 gray30 bottom
## ...392 gray30 top
## ...381 gray30 bottom
## ... ... ...
## ...319 gray30 top
## ...319 gray30 bottom
## ...386 gray30 top
## ...389 gray30 bottom
## ...376 gray30 bottom
## -------
## seqinfo: 1 sequence from an unspecified genome; no seqlengths
## Draw a lollipop plot
lolliplot(sample.gr, features.gr, legend=keys)
