| Title: | Identify Differential Selection |
|---|---|
| Description: | Tests for context-dependent selection on cancer driver genes using somatic mutation data. The package implements the DiffDriver statistical framework to assess whether the strength of positive selection on mutations in a driver gene is associated with tumor- or individual-level context variables, such as clinical traits, genomic features, or immune microenvironment subtypes. DiffDriver estimates individual- and position-specific background mutation rates, models selection as a deviation from the background rate using functional annotations, and tests context effects through a latent-variable logistic model. It provides utilities for preparing mutation and annotation data, fitting differential-selection models, running gene-level association tests, summarizing candidate genes, and visualizing mutation patterns. The method is described in Zhou et al. (2026) "Detecting context-dependent selection on cancer driver genes with DiffDriver" <doi:10.64898/2026.04.06.716771>. |
| Authors: | Siming Zhao [aut, cre] (Additional email: [email protected]), Jie Zhou [aut], Qirui Zhang [aut] |
| Maintainer: | Siming Zhao <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.8 |
| Built: | 2026-11-23 16:54:20 UTC |
| Source: | https://github.com/cran/diffdriver |
Process annotation tables within a list of mutation data.
An intercept column is added to each annotation table. When
functypecode is included in selectvars, functional
annotation codes 7 and 8 are converted to a binary indicator
named functypecode8, with values 0 and 1, respectively.
When recoding is enabled, the binary indicator is placed
immediately after the intercept, before the remaining
annotation columns.
Unlike driverMAPS, this implementation explicitly handles only
functional annotation codes 7 and 8 when functypecode is
selected. Other codes are not assigned an indicator value.
ddmcode(matrixlist, selectvars, functypecodelevel = NULL)ddmcode(matrixlist, selectvars, functypecodelevel = NULL)
matrixlist |
A list of mutation data entries. The first element of each entry contains an annotation table, and the second element contains corresponding mutation data used to determine row counts. |
selectvars |
A character vector of selected annotation variables.
The variable |
functypecodelevel |
An optional argument that is not used by the current implementation. |
The updated matrixlist, with an intercept column
added to each annotation table and functional codes recoded
when applicable.
Fit the DiffDriver model for a single gene, incorporating both sample-level phenotype information and position-level functional annotations. The position-level functional effects are supplied as inputs, while model parameters describing selection and the phenotype effect are estimated using an expectation-maximization (EM) algorithm with SQUAREM acceleration. The model tests whether the phenotype is associated with positive selection, optionally adjusting for sample-level covariates.
ddmodel(mut, e, mr, fe, label, cov = NULL, ...)ddmodel(mut, e, mr, fe, label, cov = NULL, ...)
mut |
A matrix of mutation status indicators (0 or 1), with rows corresponding to mutation positions and columns to samples. Rows sharing the same label are aggregated during model fitting. |
e |
A numeric vector of sample-level phenotype values, aligned
with the columns of |
mr |
A matrix of log-scale background mutation rates for each
mutation position and sample, not dependent on the sample-level
phenotype factor. It has the same dimensions as |
fe |
A vector of log-scale increases in mutation rate due to
position-level functional effects, aligned with the rows of
|
label |
A vector or factor of length |
cov |
an optional numeric matrix of sample-level covariates (e.g. age, sex),
with rows matching the columns (samples) of |
... |
Additional arguments passed to |
A list containing:
pvalueLikelihood-ratio test p-value comparing the null and alternative models for the phenotype effect.
res.nullNull-model fitting results, including
loglikelihood, beta0, and alpha.
res.altAlternative-model fitting results,
including loglikelihood, beta0, and
alpha.
# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix(0, nrow = 6, ncol = 20) mut[1, 1] <- 1 mut[2, 5] <- 1 mut[c(1, 2), 11] <- 1 mut[c(2, 3), 12] <- 1 mut[c(3, 4), 13] <- 1 mut[c(4, 5), 14] <- 1 mut[c(5, 6), 15] <- 1 mut[c(1, 6), 16] <- 1 mut[c(1, 3), 17] <- 1 mut[c(2, 4), 18] <- 1 mut[c(3, 5), 19] <- 1 mut[c(4, 6), 20] <- 1 e <- c(rep(0, 10), rep(1, 10)) # Mutation rates and functional effects are on the log scale. mr <- matrix(log(0.002), nrow = nrow(mut), ncol = ncol(mut)) fe <- rep(log(3), nrow(mut)) # Each row represents a separate mutation position. label <- factor(seq_len(nrow(mut))) result <- ddmodel(mut, e, mr, fe, label = label) result$pvalue # Adjust for two sample-level covariates. cov_matrix <- cbind( age = rep(c(-1, 0, 1, 0, -1), 4), sex = rep(c(0, 1), 10) ) result_cov <- ddmodel( mut, e, mr, fe, label = label, cov = cov_matrix ) result_cov$pvalue# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix(0, nrow = 6, ncol = 20) mut[1, 1] <- 1 mut[2, 5] <- 1 mut[c(1, 2), 11] <- 1 mut[c(2, 3), 12] <- 1 mut[c(3, 4), 13] <- 1 mut[c(4, 5), 14] <- 1 mut[c(5, 6), 15] <- 1 mut[c(1, 6), 16] <- 1 mut[c(1, 3), 17] <- 1 mut[c(2, 4), 18] <- 1 mut[c(3, 5), 19] <- 1 mut[c(4, 6), 20] <- 1 e <- c(rep(0, 10), rep(1, 10)) # Mutation rates and functional effects are on the log scale. mr <- matrix(log(0.002), nrow = nrow(mut), ncol = ncol(mut)) fe <- rep(log(3), nrow(mut)) # Each row represents a separate mutation position. label <- factor(seq_len(nrow(mut))) result <- ddmodel(mut, e, mr, fe, label = label) result$pvalue # Adjust for two sample-level covariates. cov_matrix <- cbind( age = rep(c(-1, 0, 1, 0, -1), 4), sex = rep(c(0, 1), 10) ) result_cov <- ddmodel( mut, e, mr, fe, label = label, cov = cov_matrix ) result_cov$pvalue
This function uses the model as cmodel.frac, but generalizes to take more than 1 functional categories. This model is applied on data of a single gene
ddmodel_binary(mut, e, bmr, fe)ddmodel_binary(mut, e, bmr, fe)
mut |
a matrix of mutation status 0 or 1 |
e |
a vector,phenotype of each sample,
should match the columns of |
bmr |
a matrix, background mutation rate of each sample at each mutation (log scale) |
fe |
a vector, increased mutation rate at each mutation, due to functional effect (log scale),
should match the rows of |
A list with the following elements:
pvalueThe likelihood-ratio test p-value comparing the null and alternative binary-phenotype models.
null.eta0The fitted null-model parameter.
alt.etaThe fitted alternative-model parameters for the two phenotype groups.
null.llThe maximized log-likelihood under the null model.
alt.llThe maximized log-likelihood under the alternative model.
allA named numeric vector containing pvalue,
null_para, e=0, e=1, null_likelihood, and
alt_likelihood.
# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 ), nrow = 3, byrow = TRUE ) e <- c(0, 0, 0, 0, 1, 1, 1, 1) # Background mutation rates and functional effects are on the log scale. bmr <- matrix(log(0.001), nrow = nrow(mut), ncol = ncol(mut)) fe <- log(c(2, 2, 2)) result <- ddmodel_binary(mut, e, bmr, fe) result$pvalue# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 ), nrow = 3, byrow = TRUE ) e <- c(0, 0, 0, 0, 1, 1, 1, 1) # Background mutation rates and functional effects are on the log scale. bmr <- matrix(log(0.001), nrow = nrow(mut), ncol = ncol(mut)) fe <- log(c(2, 2, 2)) result <- ddmodel_binary(mut, e, bmr, fe) result$pvalue
This function uses the model as cmodel.frac, but generalizes to take more than 1 functional categories. This model is applied on data of a single gene. This should give the same results as ddmodel_binary defined above.
ddmodel_binary_simple(mut, e, bmr, fe)ddmodel_binary_simple(mut, e, bmr, fe)
mut |
a matrix of mutation status 0 or 1 |
e |
a vector,phenotype of each sample,
should match the columns of |
bmr |
a matrix, background mutation rate of each sample at each mutation (log scale), as we assume bmr the same across samples, only the first column will be used. |
fe |
a vector, increased mutation rate at each mutation, due to functional effect (log scale),
should match the rows of |
A list with the following elements:
pvalueThe likelihood-ratio test p-value comparing the null and alternative binary-phenotype models.
null.eta0The fitted null-model parameter.
alt.etaThe fitted alternative-model parameters for the two phenotype groups.
null.llThe maximized log-likelihood under the null model.
alt.llThe maximized log-likelihood under the alternative model.
# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 ), nrow = 3, byrow = TRUE ) e <- c(0, 0, 0, 0, 1, 1, 1, 1) # Background mutation rates and functional effects are on the log scale. bmr <- matrix(log(0.001), nrow = nrow(mut), ncol = ncol(mut)) fe <- log(c(2, 2, 2)) result <- ddmodel_binary_simple(mut, e, bmr, fe) result$pvalue# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 ), nrow = 3, byrow = TRUE ) e <- c(0, 0, 0, 0, 1, 1, 1, 1) # Background mutation rates and functional effects are on the log scale. bmr <- matrix(log(0.001), nrow = nrow(mut), ncol = ncol(mut)) fe <- log(c(2, 2, 2)) result <- ddmodel_binary_simple(mut, e, bmr, fe) result$pvalue
This function runs diffDriver.
diffdriver( gene, mut, pheno, covariates = NULL, anno_dir = ".", k = 6, totalnttype = 96, BMRmode = c("signature", "regular"), output_dir = tempdir(), output_prefix = "diffdriver_results" )diffdriver( gene, mut, pheno, covariates = NULL, anno_dir = ".", k = 6, totalnttype = 96, BMRmode = c("signature", "regular"), output_dir = tempdir(), output_prefix = "diffdriver_results" )
gene |
A vector of genes to be included in the analysis. |
mut |
A data frame containing all somatic mutations from the cohort. The format is:
Example: Chromosome Position Ref Alt SampleID 1 19 55653236 C T TCGA-N6-A4VE-01A-11D-A28R-08 |
pheno |
A data frame containing sample phenotypes. The format is: #'
Example: SampleID SmokingCessation BMI TCGA-N5-A4R8-01A-11D-A28R-08 0.5319630 20.0 TCGA-N5-A4RD-01A-11D-A28R-08 0.0448991 24.4 |
covariates |
Optional sample-level covariates (e.g. age, sex) to adjust for.
Either a path to a delimited file or a data frame. It must contain a
Example: SampleID Age Sex TCGA-N5-A4R8-01A-11D-A28R-08 56 M TCGA-N5-A4RD-01A-11D-A28R-08 63 F The default is |
anno_dir |
The path to the directory with all the annotation files. Please download from Zenodo.The default is current folder |
k |
The number of topics used in modeling background mutation rate. The default is 6. |
totalnttype |
either 9 or 96. Will look for annotation files anno9_ntypexxx_annodata.txt when totalnttype is 9 or anno96_ntypexxx_annodata when totalnttype is 96. |
BMRmode |
There are two modes to run diffdriver. One is "signature", this will model individual level BMR, this is the default. The second one is "regular", this assumes BMR is the same across individuals, only models position-level difference. |
output_dir |
The path to the output directory. Defaults to a temporary directory. |
output_prefix |
The prefix being added to the output file names. |
A data frame with one row per tested gene. The returned columns include
dd.p, mlr.p, mlr.v2.p, fisher.p, binom.p,
and lr.p, which are p-values from DiffDriver and comparator methods;
the corresponding .fdr columns, which contain Benjamini-Hochberg adjusted
p-values; and mut.E1, mut.E0, E1, and E0, which
summarize mutation and sample counts in the two phenotype groups used by the
Fisher test.
phenof <- system.file( "extdata", "example_phenotypes.txt", package = "diffdriver" ) genef <- system.file( "extdata", "example_gene.txt", package = "diffdriver" ) mutf <- system.file( "extdata", "example_mutations.txt", package = "diffdriver" ) pheno <- read.table(phenof, header = TRUE) gene <- read.table(genef, header = FALSE) mut <- read.table(mutf, header = TRUE) ## Not run: # Download the annotation files and replace this with their directory. annodir <- "/path/to/annodir96" result <- diffdriver( gene = gene, mut = mut, pheno = pheno, anno_dir = annodir, k = 6, totalnttype = 96, BMRmode = "signature", output_dir = tempdir(), output_prefix = "diffdriver_example" ) result ## End(Not run)phenof <- system.file( "extdata", "example_phenotypes.txt", package = "diffdriver" ) genef <- system.file( "extdata", "example_gene.txt", package = "diffdriver" ) mutf <- system.file( "extdata", "example_mutations.txt", package = "diffdriver" ) pheno <- read.table(phenof, header = TRUE) gene <- read.table(genef, header = FALSE) mut <- read.table(mutf, header = TRUE) ## Not run: # Download the annotation files and replace this with their directory. annodir <- "/path/to/annodir96" result <- diffdriver( gene = gene, mut = mut, pheno = pheno, anno_dir = annodir, k = 6, totalnttype = 96, BMRmode = "signature", output_dir = tempdir(), output_prefix = "diffdriver_example" ) result ## End(Not run)
Perform a gene-level binomial test comparing mutation counts between two phenotype groups. The expected proportion of mutations in the group coded as 1 is determined by the proportion of samples in that group.
genebinom(mut, e)genebinom(mut, e)
mut |
A numeric matrix of mutation counts or indicators, with rows corresponding to mutation positions and columns corresponding to samples. |
e |
A binary phenotype or group indicator containing 0 and 1,
with one value for each column of |
A list containing:
pvalueThe p-value from a binomial test comparing the total mutation counts in the two phenotype groups, using their relative sample sizes to determine the expected proportion.
# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) result <- genebinom(mut, e) result$pvalue# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) result <- genebinom(mut, e) result$pvalue
Perform a gene-level Fisher's exact test using the
total mutation counts and sample counts from two phenotype groups.
The function constructs a 2-by-2 table from these counts and
obtains the p-value using fisher.test().
genefisher(mut, e)genefisher(mut, e)
mut |
A numeric matrix of mutation counts or indicators, with rows corresponding to mutation positions and columns corresponding to samples. |
e |
A binary phenotype or group indicator containing 0 and 1,
with one value for each column of |
A list containing:
pvalueThe p-value from the gene-level Fisher's exact test.
countA numeric vector
c(gmutc, gmutn, mu.c, mu.n), where
gmutc and gmutn are the total mutation
counts in groups 1 and 0, respectively, and
mu.c and mu.n are the corresponding
numbers of samples.
# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) result <- genefisher(mut, e) result$pvalue result$count# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) result <- genefisher(mut, e) result$pvalue result$count
Perform gene-level logistic regression to assess the association between mutation status and a binary phenotype, optionally adjusting for sample-level covariates. Mutation status is defined as 1 if a sample has at least one mutation in the gene, and 0 otherwise.
genelr(mut, e, covariates = rep(1, length(e)))genelr(mut, e, covariates = rep(1, length(e)))
mut |
A numeric matrix of mutation counts or indicators, with rows corresponding to mutation positions and columns corresponding to samples. |
e |
A binary phenotype vector containing 0 and 1,
with one value for each column of |
covariates |
Optional sample-level covariates included in
the logistic regression model, aligned with the columns of
|
A list containing:
resThe summary of the fitted logistic
regression model glm(e ~ dstatus + covariates,
family = binomial(link = "logit")).
pvalueThe p-value for the mutation-status
coefficient dstatus.
# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) # Logistic regression without additional varying covariates. result <- genelr(mut, e) result$pvalue # Logistic regression adjusting for a sample-level covariate. covariates <- c(0, 1, 0, 0, 1, 0) result_cov <- genelr(mut, e, covariates = covariates) result_cov$pvalue# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) # Logistic regression without additional varying covariates. result <- genelr(mut, e) result$pvalue # Logistic regression adjusting for a sample-level covariate. covariates <- c(0, 1, 0, 0, 1, 0) result_cov <- genelr(mut, e, covariates = covariates) result_cov$pvalue
Perform gene-level linear regression to assess the association between mutation status and a numeric phenotype, optionally adjusting for sample-level covariates. Mutation status is defined as 1 if a sample has at least one mutation in the gene, and 0 otherwise.
mlr(mut, e, covariates = rep(1, length(e)))mlr(mut, e, covariates = rep(1, length(e)))
mut |
A numeric matrix of mutation counts or indicators, with rows corresponding to mutation positions and columns corresponding to samples. |
e |
A numeric phenotype vector, with one value for each
column of |
covariates |
Optional sample-level covariate values included
in the linear regression model, aligned with the columns of
|
A list containing:
resThe summary of the fitted linear regression
model lm(e ~ dstatus + covariates).
pvalueThe p-value for the mutation-status
coefficient dstatus.
# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) # Linear regression without additional varying covariates. result <- mlr(mut, e) result$pvalue # Linear regression adjusting for a sample-level covariate. covariates <- c(0, 1, 0, 0, 1, 0) result_cov <- mlr(mut, e, covariates = covariates) result_cov$pvalue# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) # Linear regression without additional varying covariates. result <- mlr(mut, e) result$pvalue # Linear regression adjusting for a sample-level covariate. covariates <- c(0, 1, 0, 0, 1, 0) result_cov <- mlr(mut, e, covariates = covariates) result_cov$pvalue
Perform gene-level linear regression to assess the association between mutation status and a numeric phenotype, adjusting for the total number of mutations per sample. Mutation status is defined as 1 if a sample has at least one mutation in the gene, and 0 otherwise.
mlr.v2(mut, e, nmut, covariates = 1)mlr.v2(mut, e, nmut, covariates = 1)
mut |
A numeric matrix of mutation counts or indicators, with rows corresponding to mutation positions and columns corresponding to samples. |
e |
A numeric phenotype vector, with one value for each
column of |
nmut |
A numeric vector containing the total number of
mutations for each sample, aligned with the columns of
|
covariates |
An optional argument for additional covariates.
The default value |
A list containing:
resThe summary of the fitted linear regression
model lm(e ~ dstatus + nmut + covariates).
pvalueThe p-value for the mutation-status
coefficient dstatus, after adjusting for total
mutation count.
# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) # Synthetic per-sample total mutation counts. nmut <- c(3, 4, 5, 6, 7, 8) result <- mlr.v2(mut, e, nmut) result$pvalue# Synthetic mutation matrix: rows are positions and columns are samples. mut <- matrix( c( 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ), nrow = 2, byrow = TRUE ) e <- c(0, 0, 0, 1, 1, 1) # Synthetic per-sample total mutation counts. nmut <- c(3, 4, 5, 6, 7, 8) result <- mlr.v2(mut, e, nmut) result$pvalue
its like optim, but with fixed parameters.
optifix( par, fixed, fn, gr = NULL, ..., method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"), lower = -Inf, upper = Inf, control = list(), hessian = FALSE )optifix( par, fixed, fn, gr = NULL, ..., method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"), lower = -Inf, upper = Inf, control = list(), hessian = FALSE )
par |
A numeric vector of initial parameter values. |
fixed |
A logical vector of the same length as |
fn |
The objective function to be minimized. It receives the full parameter vector, including fixed parameters. |
gr |
An optional gradient function. It receives the full parameter vector. |
... |
Additional arguments passed through |
method |
The optimization method passed to |
lower |
Lower parameter bounds passed to |
upper |
Upper parameter bounds. This argument is present
in the function interface but is not passed to |
control |
A list of control parameters passed to |
hessian |
Logical; whether to request a Hessian matrix
from |
optifix. Optimise with fixed parameters
its like optim, but with fixed parameters.
specify a second argument 'fixed', a vector of TRUE/FALSE values. If TRUE, the corresponding parameter in fn() is fixed. Otherwise its variable and optimised over.
The return thing is the return thing from optim() but with a couple of extra bits - a vector of all the parameters and a vector copy of the 'fixed' argument.
Written by Barry Rowlingson <[email protected]> October 2011
This file released under a CC By-SA license: http://creativecommons.org/licenses/by-sa/3.0/
and must retain the text: "Originally written by Barry Rowlingson" in comments.
A list containing the results returned by optim(),
with two additional elements:
fullparsThe complete parameter vector, including both optimized and fixed parameters.
fixedThe logical vector identifying which parameters were held fixed.
The par element contains the optimized free parameters.
# Minimize a quadratic function while fixing the second parameter. fn <- function(p) { (p[1] - 3)^2 + (p[2] - 5)^2 } optifix_fun <- getFromNamespace("optifix", "diffdriver") fit <- optifix_fun( par = c(0, 5), fixed = c(FALSE, TRUE), fn = fn, method = "BFGS" ) fit$fullpars fit$value# Minimize a quadratic function while fixing the second parameter. fn <- function(p) { (p[1] - 3)^2 + (p[2] - 5)^2 } optifix_fun <- getFromNamespace("optifix", "diffdriver") fit <- optifix_fun( par = c(0, 5), fixed = c(FALSE, TRUE), fn = fn, method = "BFGS" ) fit$fullpars fit$value
Visualize sample-level phenotype values, mutation counts, and functional mutation annotations for a selected gene. The function draws a series of bar plots on the current graphics device using the supplied mutation and phenotype data.
plot_mut( gene_name, mut, pheno, totalnttype = 96, anno_dir = ".", output_prefix = "plot", output_dir = tempdir() )plot_mut( gene_name, mut, pheno, totalnttype = 96, anno_dir = ".", output_prefix = "plot", output_dir = tempdir() )
gene_name |
A character string specifying the gene to plot. |
mut |
A mutation data table containing sample identifiers and mutation information, including chromosome, position, reference allele, and alternative allele. |
pheno |
A table of sample-level phenotype or context data corresponding to the mutation data. |
totalnttype |
The number of nucleotide context types used
for the annotation data. Default is |
anno_dir |
Directory containing the positional annotation
files required by |
output_prefix |
Prefix passed to the positional data
preprocessing function. Default is |
output_dir |
Directory passed to the positional data
preprocessing function. Defaults to |
A numeric vector of bar midpoints returned by the final
barplot() call. The function is primarily used for its
side effect of drawing phenotype and mutation summary plots.
phenof <- system.file( "extdata", "example_phenotypes.txt", package = "diffdriver" ) mutf <- system.file( "extdata", "example_mutations.txt", package = "diffdriver" ) pheno <- read.table(phenof, header = TRUE) mut <- read.table(mutf, header = TRUE) ## Not run: # Download the annotation files and replace this with their directory. annodir <- "/path/to/annodir9" plot_mut( gene_name = "PIK3CA", mut = mut, pheno = pheno, totalnttype = 9, anno_dir = annodir, output_dir = tempdir() ) ## End(Not run)phenof <- system.file( "extdata", "example_phenotypes.txt", package = "diffdriver" ) mutf <- system.file( "extdata", "example_mutations.txt", package = "diffdriver" ) pheno <- read.table(phenof, header = TRUE) mut <- read.table(mutf, header = TRUE) ## Not run: # Download the annotation files and replace this with their directory. annodir <- "/path/to/annodir9" plot_mut( gene_name = "PIK3CA", mut = mut, pheno = pheno, totalnttype = 9, anno_dir = annodir, output_dir = tempdir() ) ## End(Not run)