ggkaryo-class: ggkaryo: a class for karyotype plotting and overlaying.

Description Fields Methods Examples

Description

The \codeggkaryo class allows to plot (labeled) ideograms and to overlay them with data track profiles and also highlight loci of interes (lois).

Fields

n_chrom

(numerical) number of chromosomes, default: 24

hetero

(character) heterosome labels (without "chr"), default: c("X", "Y")

chrom_width

(numerical) width of the ideograms, default: 1

chrom_padding

(numerical) space between ideograms, default: 5

track_palette_name

(character) name of RColorBrewer palette for track filling

lois_palette_name

(character) name of RColorBrewer palette for lois color

giemsa_palette

(character) vector of colors for the giemsa bands

giemsa_levels

(character) vector of giemsa band levels

opposite

(logical) to plot profiles on both sides of the ideogram

data

(list) contains ggkaryo data for plotting

Methods

add_arm_boxes()

Adds boxes around chromosome arms.

add_chrom_labels()

Adds chromosome labels.

add_lois(name, loiData, position, colorName, alpha = 1)

Adds details on Loci Of Interest (loi) to the current ggkaryo plot. Builds .self\$data[['lois']].

name

(character) loi track name for legend

loiData

(character) path to BED5+ loi file

loiData

(data.table) data.table with BED5+ loi data

position

(character) either 'left', 'right' or 'center'

colorName

(character) column with color factors

alpha

(numeric) opacity level

add_lois_overlay()

Overlays track profiles to a ggkaryo plot.

add_track(name, track, step, position = "auto", color = "auto", alpha = 0.5)

Adds a profile to the current ggkaryo plot. The input track must have already been binned with a consistent step. A consistent step is needed to automatically set any gap to 0 in the profile. Builds .self\$data[['tracks']].

name

(character) track name for legend

track

(character) path to BED5+ file

track

(data.table) BED5+ data table

step

(numerical) bin step in nt

position

(character) one of auto|left|right. 'left' can be used only if opposite=T was used when initializing the ggkaryo object

color

(character) either 'auto' or a color string

alpha

(numerical) opacity level.

add_track_overlay()

Overlays track profiles to a ggkaryo plot.

bin_track(track, size, step, method = "within", fun.aggreg = mean, ...)

Bins a track based on provided bin size and step. Regions from the track are assigned to the bins when they are completely include ('within' method) or overlap even partially ('overlap' method).

track

(data.table) BED5+ track data table

size

(numeric) bin size in nt

step

(numeric) bin step in nt

method

(string) either 'within' or 'overlap'

fun.aggreg

(function) how to aggregate values in bins

...

(mixed) additional parameters to pass to fun.aggreg

returns

data.table: binned track

chrom2id(chrom)

Converts a chromosome signature (seqname) to a numerical id.

chrom

(string) chromosome signature (e.g., 'chr1' or '1')

returns

numeric: chromosome numerical ID

chromID2x(chromID)

Retrieve the position of a chromosome on the X axis.

chromID

(numeric)

returns

numeric: chromosome position on the X axis

get_color(color, trackID)

Extracts, in order, track colors from the .self\$track_palette_name. See RColorBrewer for more details.

color

(character) a color or 'auto'

trackID

(numeric) track number

get_next_position(position)

Selects position for the next track in such a fashion to balance out left/right sides of the ideograms.

position

(character) 'right', 'left', or 'auto'

initialize(giemsa, ..., n_chrom = 24, hetero = c("X", "Y"), chrom_width = 1, chrom_padding = 5, track_palette_name = "Paired", lois_palette_name = "Dark2", giemsa_palette = c("#DDDDDD", "#9A9A9A", "#787878", "#555555", "#333333", "#FF0000", "#C4FFFC", "#AFE6FF"), giemsa_levels = c("gneg", "gpos25", "gpos50", "gpos75", "gpos100", "acen", "gvar", "stalk"), opposite = FALSE, show_giemsa_guide = F, show_tracks_guide = F, show_arm_boxes = F, show_chrom_labels = F)

Initializer method. See ggkaryo description for more details

norm2x(chromID, norm, position)

Converts normalized score to X coordinate in the ggkaryo plot.

chromID

(numeric)

norm

(numeric) normalized score

position

(character) 'left' or 'right'

returns

numeric: normalized score X coordinate

plot_base()

Plots the current ggkaryo object (only basic layers).

plot_full(doPrep = T)

Plots the current ggkaryo object with tracks and lois.

prep4bands()

Prepares data for plotting chromosome bands. Builds .self\$data[['bands']] object.

prep4boxes()

Prepares data for plotting chromosome arm boxes. Chromosome arms are identified based on the 'acen' bands that are used to divide each chromosomes in two arms. Builds .self\$data[['boxes']] object.

prep4fullplot()

Prepares to plot the full ggkaryo object.

prep4karyo(giemsa)

Builds a data.table to plot the ideograms and (optionally) boxes around each chromosome arm.

giemsa

(character) path to giemsa BED5+ file

giemsa

(data.table) data table with giemsa BED5+ data

returns

data.table: adjusted giemsa data.table

prep4labels()

Prepares data for plotting chromosome labels. Builds .self\$data[['chrom_labels']] object.

prep4plot()

Prepares for plotting. Builds .self\$data[['plot']] object.

read_giemsa(giemsa)

Reads a Giemsa bed file. Adds chromID, bandID, and X columns.

giemsa

(character) path to giemsa BED5+ file

giemsa

(data.table) data table with giemsa BED5+ data

returns

data.table: adjusted giemsa data.table

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
require(data.table)
require(ggkaryo2)

# Load example data
data('giemsa', package='ggkaryo2')
data('track', package='ggkaryo2')
data('lois', package='ggkaryo2')

# Plot ideogram
ggk = ggkaryo(giemsa)
ggk$plot_full()

# Plot ideogram with boxes around chromosome arms and labels
ggk = ggkaryo(giemsa, show_arm_boxes=T, show_chrom_labels=T)
ggk$plot_full()

# Plot ideogram with one profile track
ggk = ggkaryo(giemsa)
binnedTrack = track
ggk$add_track("track", binnedTrack, 1e5)
ggk$plot_full()

# Plot ideogram with two profile tracks on the same side
ggk = ggkaryo(giemsa)
binnedTrack2 = copy(binnedTrack)
binnedTrack2[, value := value*abs(rnorm(nrow(binnedTrack2)))]
ggk$add_track("track 1", binnedTrack, 1e5)
ggk$add_track("track 2", binnedTrack2, 1e5)
ggk$plot_full()

# Plot ideogram with two profile tracks on opposite sides
ggk = ggkaryo(giemsa, opposite=TRUE)
binnedTrack2 = copy(binnedTrack)
binnedTrack2[, value := value*abs(rnorm(nrow(binnedTrack2)))]
ggk$add_track("track 1", binnedTrack, 1e5)
ggk$add_track("track 2", binnedTrack2, 1e5)
ggk$plot_full()

# Plot ideogram with two profile tracks on opposite sides and central lois
ggk = ggkaryo(giemsa)
binnedTrack2 = copy(binnedTrack)
binnedTrack2[, value := value*abs(rnorm(nrow(binnedTrack2)))]
ggk$add_track("track 1", binnedTrack, 1e5)
ggk$add_track("track 2", binnedTrack2, 1e5)
loiData = lois
ggk$add_lois("Sample type", loiData, "center", "sample")
ggk$plot_full()

# Plot ideogram with two profile tracks on opposite sides and central lois
# Showing all legends
ggk = ggkaryo(giemsa, show_arm_boxes=T, show_chrom_labels=T,
  show_giemsa_guide = T, show_tracks_guide = T)
binnedTrack2 = copy(binnedTrack)
binnedTrack2[, value := value*abs(rnorm(nrow(binnedTrack2)))]
ggk$add_track("track 1", binnedTrack, 1e5)
ggk$add_track("track 2", binnedTrack2, 1e5)
loiData = lois
ggk$add_lois("Sample type", loiData, "center", "sample")
ggk$plot_full()

ggirelli/ggkaryo2 documentation built on June 25, 2020, 10:08 a.m.