How it works...

The code first loads the libraries we'll need, then we construct a data.frame describing the genome we want to draw, with names and lengths set accordingly. The data.frame is then converted to genome_gr—a GRanges object with the makeGRangesFromDataFrame() conversion function. Next, we create a data.frame of 25 random SNPs using the sample() function to choose a position and chromosome. Again, this is converted to GRanges. Now we can set up our plot. First, we get the default plot parameter object from inside the package using getDefaultPlotParams(). We can modify this object to make any changes to the default settings in our plot.

Note we have selected plot.type = 1—this is a simple plot with one data track directly above each chromosome region. We'll need to change the margin height of the data track to stop our marker labels pouring out over the top—this is done with plot.params$data1outmargin <- 600. Finally, we can draw our plot; we create the base plot object, kp, by calling plotKaryotype() and passing in the genome_gr object, plot.type, and the parameters in the modified plot.params object.

This will result in the following output:

Our markers are drawn using the kpPlotMarkers() function with the new kp plot object, the snps_gr data, and the SNP labels.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.66.149