freq_peak_plot: Plot freq_peak object

View source: R/freq_peak_plot.R

freq_peak_plotR Documentation

Plot freq_peak object

Description

Converts allele balance data produced by freq_peak() to a copy number by assinging the allele balance data (frequencies) to its closest expected ratio.

Usage

freq_peak_plot(
  pos,
  posUnits = "bp",
  ab1 = NULL,
  ab2 = NULL,
  fp1 = NULL,
  fp2 = NULL,
  mySamp = 1,
  col1 = "#A6CEE3",
  col2 = "#1F78B4",
  alpha = 44,
  main = NULL,
  mhist = TRUE,
  layout = TRUE,
  ...
)

Arguments

pos

chromosomal position of variants

posUnits

units ('bp', 'Kbp', 'Mbp', 'Gbp') for 'pos' to be converted to in the main plot

ab1

matrix of allele balances for allele 1

ab2

matrix of allele balances for allele 2

fp1

freq_peak object for allele 1

fp2

freq_peak object for allele 2

mySamp

sample indicator

col1

color 1

col2

color 2

alpha

sets the transparency for dot plot (0-255)

main

main plot title.

mhist

logical indicating to include a marginal histogram

layout

call layout

...

parameters passed on to other functions

Details

Creates a visualization of allele balance data consisting of a dot plot with position as the x-axis and frequency on the y-axis and an optional marginal histogram. The only required information is a vector of chromosomal positions, however this is probably not going to create an interesting plot.

Value

An invisible NULL.

See Also

freq_peak, peak_to_ploid

Examples


# An empty plot.
freq_peak_plot(pos=1:40)

data(vcfR_example)
gt <- extract.gt(vcf)
hets <- is_het(gt)
# Censor non-heterozygous positions.
is.na(vcf@gt[,-1][!hets]) <- TRUE
# Extract allele depths.
ad <- extract.gt(vcf, element = "AD")
ad1 <- masplit(ad, record = 1)
ad2 <- masplit(ad, record = 2)
freq1 <- ad1/(ad1+ad2)
freq2 <- ad2/(ad1+ad2)
myPeaks1 <- freq_peak(freq1, getPOS(vcf))
is.na(myPeaks1$peaks[myPeaks1$counts < 20]) <- TRUE
myPeaks2 <- freq_peak(freq2, getPOS(vcf), lhs = FALSE)
is.na(myPeaks2$peaks[myPeaks2$counts < 20]) <- TRUE
freq_peak_plot(pos = getPOS(vcf), ab1 = freq1, ab2 = freq2, fp1 = myPeaks1, fp2=myPeaks2)




vcfR documentation built on May 29, 2024, 10:57 a.m.