R/plot_simulated_chromosome_segments.R
plot_simulated_chromomsome_segments.Rd
This function uses the information in the tibble about segments dropped down a genome simulation pedigree to plot the chromomomes of an individual colored by the population of origin of each segment.
a tibble of segments
a tibble of recombination rates in bins in the format of RecRates. If this is included, the recombination rates in cM/Mb are plotted atop the chromosomes as a little sparkline. If it is not included, then the there are no little sparklines above the chromosomes.
If FALSE (the default) the fill color of segments
is mapped to the pop_origin, which is where the founder haplotypes came from according
to the hpop1
and hpop2
columns in the GSP specification. If you set this
to TRUE, then we map the "group" column of the reppop to fill.
a vector the the relative heights of the different elements of each chromosomal unit of the plot. This is a named vector with the following elements, listed in order of the bottom of each unit to the top:
chrom_ht
: the height of the bars for each of the two chromosomes of the
pair in a chromosome unit.
chrom_gap
: The gap between the two homologous chromosomes of the individual.
spark_gap
: the gap between the top chromosome and the sparkline box
for recombination rates.
spark_box
: height of the box within which the sparkline goes. Note that
the sparkline itself will be scaled so that the highest rate anywhere within
the genome will correspond to the top of the spark box.
unit_gap
: The relative height of the gap between one chromosome unit and
the next.
the y value of the bottom chromosome unit. Basically the absolute distance between the y=0 line and the start of the plotted material. Should typically be between 0 and 1.
thickness of the line that draws the recombination rate sparkline.
fraction by which the unit gap should be reduced when there are sparklines being drawn.
This function returns a ggplot object. Each facet of the plot shows
the chromosomes of a different sampled individual from a particular replicate
simulation from a particular genome simulation pedigree. The facets are titled
like: GSP 1, Idx 2, ID 8[3]
, which means that the chromosomes shown in the panel
are from the third sampled set of chromosomes from the individual with ID 8 from the
simulation from genome simulation pedigree 1 with index 2.
s <- example_segments
rr <- RecRates
g <- plot_simulated_chromomsome_segments(s)
g_with_sparklines <- plot_simulated_chromomsome_segments(s, rr)