Title: | Visualize and Parse the Output of 'BeXY' |
---|---|
Description: | Provides functions for summarizing and plotting the output of the command-line tool 'BeXY' (<https://bitbucket.org/wegmannlab/bexy>), a tool that performs Bayesian inference of sex chromosome karyotypes and sex-linked scaffolds from low-depth sequencing data. |
Authors: | Madleina Caduff [aut, cre], Raphael Eckel [ctb], Christoph Leuenberger [ctb], Daniel Wegmann [aut] |
Maintainer: | Madleina Caduff <[email protected]> |
License: | GPL-2 |
Version: | 0.1.3 |
Built: | 2024-12-22 06:43:56 UTC |
Source: | CRAN |
Visualization of results produced by BeXY
bexy(path = NULL, readMCMCTrace = FALSE)
bexy(path = NULL, readMCMCTrace = FALSE)
path |
The path where all the output files of BeXY are located. If NULL, the example files will be loaded. |
readMCMCTrace |
If TRUE, read the full trace of the MCMC of all parameters (potentially slow). |
An object of type bexy.
Getting posterior mean rho (ploidy ratio parameter) for each scaffold
getPosteriorMeanRho(object)
getPosteriorMeanRho(object)
object |
A bexy object. |
A numeric vector containing the posterior mean of rho for each scaffold
bex <- bexy() getPosteriorMeanRho(bex)
bex <- bexy() getPosteriorMeanRho(bex)
Getting the posterior mode for each autosomal trisomy
getPosteriorModeAutosomalTrisomy( object, scaffoldName, threshold_certainty = 0.9 )
getPosteriorModeAutosomalTrisomy( object, scaffoldName, threshold_certainty = 0.9 )
object |
A bexy object. |
scaffoldName |
The scaffold name, must be an autosome. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All samples that have a posterior probability less than this threshold are classified as 'uncertain'. |
A character vector containing the trisomy classification for each sample for the given scaffold
bex <- bexy() getPosteriorModeAutosomalTrisomy(bex, "21")
bex <- bexy() getPosteriorModeAutosomalTrisomy(bex, "21")
Getting the posterior mode for each scaffold type
getPosteriorModeScaffoldTypes(object, threshold_certainty = 0.9)
getPosteriorModeScaffoldTypes(object, threshold_certainty = 0.9)
object |
A bexy object. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All scaffolds that have a posterior probability less than this threshold are classified as 'uncertain'. |
A character vector containing the scaffold type classification for each scaffold
bex <- bexy() getPosteriorModeScaffoldTypes(bex)
bex <- bexy() getPosteriorModeScaffoldTypes(bex)
Getting the posterior mode for each sex karyotype
getPosteriorModeSexKaryotypes(object, threshold_certainty = 0.9)
getPosteriorModeSexKaryotypes(object, threshold_certainty = 0.9)
object |
A bexy object. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All samples that have a posterior probability less than this threshold are classified as 'uncertain'. |
A character vector containing the sex karyotype classification for each sample
bex <- bexy() getPosteriorModeSexKaryotypes(bex)
bex <- bexy() getPosteriorModeSexKaryotypes(bex)
Getting all samples classified as a certain autosomal trisomy
getSamplesWithAutosomalTrisomy(object, scaffoldName, threshold_certainty = 0.9)
getSamplesWithAutosomalTrisomy(object, scaffoldName, threshold_certainty = 0.9)
object |
A bexy object. |
scaffoldName |
The scaffold name, must be an autosome. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All samples that have a posterior probability less than this threshold are classified as 'uncertain'. |
A character vector containing all sample names that are classified as having an autosomal trisomy of scaffold 'scaffoldName'
bex <- bexy() getSamplesWithAutosomalTrisomy(bex, "21")
bex <- bexy() getSamplesWithAutosomalTrisomy(bex, "21")
Getting all samples classified as a specific sex karyotype
getSamplesWithThisKaryotype(object, karyotype, threshold_certainty = 0.9)
getSamplesWithThisKaryotype(object, karyotype, threshold_certainty = 0.9)
object |
A bexy object. |
karyotype |
One specific sex karyotype, can be XY, XX, X0, XXY, XYY, XXX or XXYY. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All samples that have a posterior probability less than this threshold are classified as 'uncertain'. |
A character vector containing all sample names that are classified as the sex karyotype given by argument 'karyotype'.
bex <- bexy() getSamplesWithThisKaryotype(bex, "XX")
bex <- bexy() getSamplesWithThisKaryotype(bex, "XX")
Getting all scaffolds classified as a specific scaffold type
getScaffoldsWithThisType(object, type, threshold_certainty = 0.9)
getScaffoldsWithThisType(object, type, threshold_certainty = 0.9)
object |
A bexy object. |
type |
One specific scaffold type, can be Autosome, Y-linked, X-linked or Different. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All scaffolds that have a posterior probability less than this threshold are classified as 'uncertain'. |
A character vector containing all scaffold names that are classified as the scaffold type given by argument 'type'.
bex <- bexy() getScaffoldsWithThisType(bex, "X-linked")
bex <- bexy() getScaffoldsWithThisType(bex, "X-linked")
Plotting a bexy object. To customize the plots, please call the respective plotting functions directly (e.g. plotTernary, plotCounts, plotBars...).
## S3 method for class 'bexy' plot(x, ...)
## S3 method for class 'bexy' plot(x, ...)
x |
A bexy object. |
... |
Other parameters used for plotting. |
No return value, called for side effects.
bex <- bexy() plot(bex)
bex <- bexy() plot(bex)
Plotting the autosomal trisomies
plotAutosomalTrisomy( x, scaffoldName, colors = c("deepskyblue4", "darkred"), sampleNamesToHighlight = c(), label = TRUE, ... )
plotAutosomalTrisomy( x, scaffoldName, colors = c("deepskyblue4", "darkred"), sampleNamesToHighlight = c(), label = TRUE, ... )
x |
A bexy object. |
scaffoldName |
The name of the scaffold to plot (has to be an autosome) |
colors |
A vector of length two with the colors for diploid and triploid samples, respectively. |
sampleNamesToHighlight |
A vector of sample names that should be highlighted. If empty, samples are automatically highlighted based on the posterior probabilities. |
label |
Boolean indicating whether samples should be labeled. |
... |
Other parameters used for plotting. |
No return value, called for side effects.
bex <- bexy() plotAutosomalTrisomy(bex, "21")
bex <- bexy() plotAutosomalTrisomy(bex, "21")
Plotting the autosomal trisomies: counts on that scaffold
plotAutosomalTrisomyCounts( x, scaffoldName, colors = c("deepskyblue4", "darkred"), sampleNamesToHighlight = c(), label = TRUE, ... )
plotAutosomalTrisomyCounts( x, scaffoldName, colors = c("deepskyblue4", "darkred"), sampleNamesToHighlight = c(), label = TRUE, ... )
x |
A bexy object. |
scaffoldName |
The name of the scaffold to plot (has to be an autosome) |
colors |
A vector of length two with the colors for diploid and triploid samples, respectively. |
sampleNamesToHighlight |
A vector of sample names that should be highlighted. If empty, samples are automatically highlighted based on the posterior probabilities. |
label |
Boolean indicating whether samples should be labeled. |
... |
Other parameters used for plotting. |
No return value, called for side effects.
bex <- bexy() plotAutosomalTrisomyCounts(bex, "21")
bex <- bexy() plotAutosomalTrisomyCounts(bex, "21")
Plotting the autosomal trisomies: posterior probabilities
plotAutosomalTrisomyPosteriorProbabilities( x, scaffoldName, colors = c("deepskyblue4", "darkred"), sampleNamesToHighlight = c(), label = TRUE, ... )
plotAutosomalTrisomyPosteriorProbabilities( x, scaffoldName, colors = c("deepskyblue4", "darkred"), sampleNamesToHighlight = c(), label = TRUE, ... )
x |
A bexy object. |
scaffoldName |
The name of the scaffold to plot (has to be an autosome) |
colors |
A vector of length two with the colors for diploid and triploid samples, respectively. |
sampleNamesToHighlight |
A vector of sample names that should be highlighted. If empty, samples are automatically highlighted based on the posterior probabilities. |
label |
Boolean indicating whether samples should be labeled. |
... |
Other parameters used for plotting. |
No return value, called for side effects.
bex <- bexy() plotAutosomalTrisomyPosteriorProbabilities(bex, "21")
bex <- bexy() plotAutosomalTrisomyPosteriorProbabilities(bex, "21")
Plotting a barplot with the posterior probabilities of each sex karyotype per sample
plotBars( x, colors = c("lightblue", "lightpink", "khaki", "maroon1", "dodgerblue3", "red4", "navy"), maxNumSamplesPerPlot = 100, sortByKaryotype = TRUE, sampleNames = c(), ... )
plotBars( x, colors = c("lightblue", "lightpink", "khaki", "maroon1", "dodgerblue3", "red4", "navy"), maxNumSamplesPerPlot = 100, sortByKaryotype = TRUE, sampleNames = c(), ... )
x |
A bexy object. |
colors |
A vector of length 7 with the colors for XY, XX, X0, XXY, XYY, XXX and XXYY, respectively. |
maxNumSamplesPerPlot |
How many samples to place next to each other into one barplot. If there are more samples, multiple barplots will be generated. This is to ensure that the labels are readable. |
sortByKaryotype |
If TRUE, the samples (i.e. the bars) are ordered by the posterior mode of the sex karyotype. |
sampleNames |
A vector of sample names that represents the order in which the bars are plotted. Overrides any argument given to sortByKaryotype. |
... |
Other parameters used for plotting. |
No return value, called for side effects.
bex <- bexy() plotBars(bex)
bex <- bexy() plotBars(bex)
Plotting the percentage of counts mapping to two scaffolds (by default a Y-linked scaffold against a X-linked scaffold), colored by sex karyotype
plotCounts( x, scaffoldX = NULL, scaffoldY = NULL, colors = c("turquoise3", "darkorange", "royalblue4"), sampleNamesToHighlight = c(), label = TRUE, ... )
plotCounts( x, scaffoldX = NULL, scaffoldY = NULL, colors = c("turquoise3", "darkorange", "royalblue4"), sampleNamesToHighlight = c(), label = TRUE, ... )
x |
A bexy object. |
scaffoldX |
A string with the name of the scaffold to be plotted on the x-axis. If NULL (default), a X-linked scaffold is used. |
scaffoldY |
A string with the name of the scaffold to be plotted on the y-axis. If NULL (default), a Y-linked scaffold is used. |
colors |
A vector of length three with the colors for aneuploid, XX and XY samples, respectively. |
sampleNamesToHighlight |
A vector of sample names that should be highlighted. If empty, samples are automatically highlighted based on the posterior probabilities. |
label |
Boolean indicating whether samples should be labeled. |
... |
Other parameters used for plotting. |
No return value, called for side effects.
bex <- bexy() plotCounts(bex)
bex <- bexy() plotCounts(bex)
Plot the MCMC trace for a specific parameter
plotMCMCTrace(object, parameterName, maxNumPlots = 20)
plotMCMCTrace(object, parameterName, maxNumPlots = 20)
object |
A bexy object. |
parameterName |
The name of the parameter to plot (e.g. rho, logSigma, epsilon, s, t, a, f, ...) |
maxNumPlots |
The maximum number of plots to plot, default 20. |
No return value, called for side effects.
bex <- bexy(readMCMCTrace = TRUE) plotMCMCTrace(bex, "rho", maxNumPlots = 1)
bex <- bexy(readMCMCTrace = TRUE) plotMCMCTrace(bex, "rho", maxNumPlots = 1)
Plotting the ternary of a bexy object
plotTernary( x, colors = c("turquoise3", "darkorange", "royalblue4"), sampleNamesToHighlight = c(), label = TRUE, addSquares = TRUE, ... )
plotTernary( x, colors = c("turquoise3", "darkorange", "royalblue4"), sampleNamesToHighlight = c(), label = TRUE, addSquares = TRUE, ... )
x |
A bexy object. |
colors |
A vector of length three with the colors for aneuploid, XX and XY samples, respectively. |
sampleNamesToHighlight |
A vector of sample names that should be highlighted. If empty, samples are automatically highlighted based on the posterior probabilities. |
label |
Boolean indicating whether samples should be labeled. |
addSquares |
Boolean indicating whether 7-cell posterior probability square plots should be drawn. |
... |
Other parameters used for plotting. |
No return value, called for side effects.
bex <- bexy() plotTernary(bex)
bex <- bexy() plotTernary(bex)
Printing a bexy object
## S3 method for class 'bexy' print(x, ...)
## S3 method for class 'bexy' print(x, ...)
x |
A bexy object. |
... |
Additional parameters passed to print functions. |
No return value, called for side effects.
bex <- bexy() print(bex)
bex <- bexy() print(bex)
Summarizing a bexy object
## S3 method for class 'bexy' summary(object, ...)
## S3 method for class 'bexy' summary(object, ...)
object |
A bexy object. |
... |
Additional parameters passed to summary functions. |
No return value, called for side effects.
bex <- bexy() print(bex)
bex <- bexy() print(bex)
Write a file with the posterior mode for each autosomal trisomy
writePosteriorModeAutosomalTrisomies( object, scaffoldName, file, threshold_certainty = 0.9 )
writePosteriorModeAutosomalTrisomies( object, scaffoldName, file, threshold_certainty = 0.9 )
object |
A bexy object. |
scaffoldName |
The scaffold name, must be an autosome. |
file |
The name of the output file. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All samples that have a posterior probability less than this threshold are classified as 'uncertain'. |
No return value, called for side effects.
bex <- bexy() tf <- tempfile(fileext = ".txt") writePosteriorModeAutosomalTrisomies(bex, "21", tf)
bex <- bexy() tf <- tempfile(fileext = ".txt") writePosteriorModeAutosomalTrisomies(bex, "21", tf)
Write a file with the posterior mode for each scaffold type
writePosteriorModeScaffoldTypes(object, file, threshold_certainty = 0.9)
writePosteriorModeScaffoldTypes(object, file, threshold_certainty = 0.9)
object |
A bexy object. |
file |
The name of the output file. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All scaffolds that have a posterior probability less than this threshold are classified as 'uncertain'. |
No return value, called for side effects.
bex <- bexy() tf <- tempfile(fileext = ".txt") writePosteriorModeScaffoldTypes(bex, tf)
bex <- bexy() tf <- tempfile(fileext = ".txt") writePosteriorModeScaffoldTypes(bex, tf)
Write a file with the posterior mode for each sex karyotype
writePosteriorModeSexKaryotypes(object, file, threshold_certainty = 0.9)
writePosteriorModeSexKaryotypes(object, file, threshold_certainty = 0.9)
object |
A bexy object. |
file |
The name of the output file. |
threshold_certainty |
The threshold for certainty on the posterior probabilities. All samples that have a posterior probability less than this threshold are classified as 'uncertain'. |
No return value, called for side effects.
bex <- bexy() tf <- tempfile(fileext = ".txt") writePosteriorModeSexKaryotypes(bex, tf)
bex <- bexy() tf <- tempfile(fileext = ".txt") writePosteriorModeSexKaryotypes(bex, tf)