layout_karyogram-method: Create a karyogram layout

Description Usage Arguments Value Author(s) Examples

Description

Create a karyogram layout.

Usage

1
2
3
4
## S4 method for signature 'GRanges'
layout_karyogram(data, ..., xlab, ylab, main,
          facets = seqnames ~ ., cytobands = FALSE, geom = "rect",
          stat = NULL, ylim = NULL, rect.height = 10)

Arguments

data

a GRanges object, which could contain extra information about cytobands. If you want an accurate genome mapping, please provide seqlengths with this GRanges object,otherwise it will emit a warning and use data space to estimate the chromosome space which is very rough.

...

Extra parameters such as aes() or arbitrary color and size.

xlab

character vector or expression for x axis label.

ylab

character vector or expression for y axis label.

main

character vector or expression for plot title.

facets

faceting formula to use.

cytobands

logical value indicate to show the cytobands or not.

geom

The geometric object to use display the data.

stat

character vector specifying statistics to use.

ylim

limits for y axis, usually the chromosome spaces y limits are from 0 to rect.height, which 10, so if you wan to stack some data on top of it, you can set limits to like c(10, 20).

rect.height

numreic value indicate half of the rectangle ploting region, used for alignment of multiple layers.

Value

A 'Layer'.

Author(s)

Tengfei Yin

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
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
### R code from vignette source 'karyogram.Rnw'

###################################################
### code chunk number 1: loading
###################################################
library(ggbio)
data(hg19IdeogramCyto, package = "biovizBase")
head(hg19IdeogramCyto)
## default pre-set color stored in 
getOption("biovizBase")$cytobandColor


###################################################
### code chunk number 2: default
###################################################
autoplot(hg19IdeogramCyto, layout = "karyogram", cytobands = TRUE)



###################################################
### code chunk number 3: change-order
###################################################
library(GenomicRanges)
hg19 <- keepSeqlevels(hg19IdeogramCyto, paste0("chr", c(1:22, "X", "Y")))
head(hg19)
autoplot(hg19, layout = "karyogram", cytobands = TRUE)


###################################################
### code chunk number 4: cyto-normal
###################################################
library(GenomicRanges)
## it's a 'ideogram'
biovizBase::isIdeogram(hg19)
## set to FALSE
autoplot(hg19, layout = "karyogram", cytobands = FALSE, aes(fill = gieStain)) +
  scale_fill_giemsa()


###################################################
### code chunk number 5: load-RNAediting
###################################################
data(darned_hg19_subset500, package = "biovizBase")
dn <- darned_hg19_subset500
head(dn)
## add seqlengths
## we have seqlegnths information in another data set
data(hg19Ideogram, package = "biovizBase")
seqlengths(dn) <- seqlengths(hg19Ideogram)[names(seqlengths(dn))]
## now we have seqlengths
head(dn)
## then we change order
dn <- keepSeqlevels(dn, paste0("chr", c(1:22, "X")))
autoplot(dn, layout = "karyogram")
## this equivalent to 
## autoplot(seqinfo(dn))


###################################################
### code chunk number 6: load-RNAediting-color
###################################################
## since default is geom rectangle, even though it's looks like segment
## we still use both fill/color to map colors
autoplot(dn, layout = "karyogram", aes(color = exReg, fill = exReg))


###################################################
### code chunk number 7: load-RNAediting-color-NA
###################################################
## since default is geom rectangle, even though it's looks like segment
## we still use both fill/color to map colors
autoplot(dn, layout = "karyogram", aes(color = exReg, fill = exReg)) +
  scale_color_discrete(na.value = "brown")


###################################################
### code chunk number 8: load-RNAediting-color-fake
###################################################
dn2 <- dn
seqlengths(dn2) <- rep(max(seqlengths(dn2)), length(seqlengths(dn2)) )
autoplot(dn2, layout = "karyogram", aes(color = exReg, fill = exReg)) 


###################################################
### code chunk number 9: plotKaryogram (eval = FALSE)
###################################################
## plotKaryogram(dn)
## plotKaryogram(dn, aes(color = exReg, fill = exReg))


###################################################
### code chunk number 10: low-default
###################################################
## plot ideogram
p <- ggplot(hg19) + layout_karyogram(cytobands = TRUE)
p
## eqevelant autoplot(hg19, layout = "karyogram", cytobands = TRUE)


###################################################
### code chunk number 11: low-default-addon
###################################################
p <- p + layout_karyogram(dn, geom = "rect", ylim = c(11, 21), color = "red")
## commented line below won't work
## the cytoband fill color has been used already.
## p <- p + layout_karyogram(dn, aes(fill = exReg, color = exReg), geom = "rect")
p


###################################################
### code chunk number 12: edit-space
###################################################
## plot chromosome space
p <- autoplot(seqinfo(dn))
## make sure you pass rect as geom
## otherwise you just get background
p <- p + layout_karyogram(dn, aes(fill = exReg, color = exReg), geom = "rect")
values(dn)$pvalue <- rnorm(length(dn))
p + layout_karyogram(dn, aes(x = start, y = pvalue), ylim = c(10, 30), geom = "line", color = "red")
p


###################################################
### code chunk number 13: sessionInfo
###################################################
sessionInfo()

ggbio documentation built on Nov. 8, 2020, 5:04 p.m.