API Reference

DiscoverMatrix(events[, bg, strata])

Class to store a binary alteration matrix and the corresponding alteration probability estimates.

pairwise_discover_test(x[, g, alternative, …])

Perform many pairwise mutual exclusivity or co-occurrence tests.

PairwiseDiscoverResult(pvalues, qvalues, …)

Class to store the results of the pairwise_discover_test function.

row_stack(matrices)

Stack DiscoverMatrix objects row-wise.

Alteration matrices

class discover.DiscoverMatrix(events, bg=None, strata=None)

Class to store a binary alteration matrix and the corresponding alteration probability estimates.

Parameters
eventspandas.DataFrame

Binary alteration matrix.

bgpandas.DataFrame, optional

Matrix of alteration probabilities for events. Mainly for internal use only. Use at your own risk.

strataarray_like, optional

To perform a stratified DISCOVER test, this array should contain the strata. The length of this array must match the number of columns of events.

Attributes
eventsndarray

Binary alteration matrix.

bgndarray

Matrix with estimated (background) alteration probabilities.

rownamesndarray

Array containing the row names for events and bg.

colnamesndarray

Array containing the column names for events and `bg.

shapetuple of int

The shape of events and bg.

discover.row_stack(matrices)

Stack DiscoverMatrix objects row-wise.

Parameters
matricessequence of DiscoverMatrix

Sequence containing the DiscoverMatrix objects to be stacked. The matrices must have the same number of columns, and the column names must match.

Returns
resultDiscoverMatrix

The matrix formed by stacking the given matrices.

Pairwise co-occurrence and mutual exclusivity tests

discover.pairwise_discover_test(x, g=None, alternative='less', fdr_method='DBH')

Perform many pairwise mutual exclusivity or co-occurrence tests.

Parameters
xDiscoverMatrix
garray_like, optional

An optional grouping vector for the rows of x. Pairs of rows within the same group are not tested.

alternative{‘less’, ‘greater’}, optional

If ‘less’, a mutual-exclusivity analysis is performed, if ‘greater’ a co-occurrence analysis.

fdr_method{‘DBH’, ‘BH’}, optional

The false discovery rate procedure used for multiple testing correction. If ‘DBH’, a Benjamini-Hochberg procedure adapted for discrete test statistics is used. If ‘BH’, the standard Benjamini-Hochberg procedure is used. The latter is much faster, but also more conservative than the discrete version.

Returns
resultPairwiseDiscoverResult

An object containing the test results for all pairwise combinations.

class discover.pairwise.PairwiseDiscoverResult(pvalues, qvalues, pi0, alternative, fdr_method)

Class to store the results of the pairwise_discover_test function.

Attributes
pvalues, qvaluespandas.DataFrame

Matrices containing the pairwise DISCOVER test P values and FDR-corrected Q values. The P value corresponding to a gene pair (gene1, gene2) is stored in either pvalues.ix[gene1, gene2] or pvalues.ix[gene2, gene1]. The other entry will contain nan. Q values are stored in the same way.

pi0float

Estimate of the proportion of true null hypotheses.

alternative{‘less’, ‘greater’}

If ‘less’, these results relate to mutual exclusivity, if ‘greater’ to co-occurrence.

fdr_method{‘DBH’, ‘BH’}

The method used to estimate these results’ q-values.

significant_pairs(q_threshold=0.01)

Return the gene pairs significant at a specified maximum false discovery rate.

Parameters
q_thresholdfloat, optional

The maximum false discovery rate (default 0.01) for test results included in the result.

Returns
resultpandas.DataFrame

DataFrame with significant gene pairs. The gene names are stored in the columns gene1 and gene2. The columns pvalue and qvalue contain the DISCOVER test P value and the FDR-corrected Q value.

Groupwise mutual exclusivity tests

discover.groupwise_discover_test(events, method='impurity')

Perform a groupwise mutual exclusivity test.

Parameters
eventsDiscoverMatrix

Matrix with rows corresponding to the genes in the gene set to be tested.

method{‘impurity’, ‘coverage’, ‘exclusivity’}

The mutual exclusivity statistic to estimate significance for.

Returns
pvaluefloat

The P value of the groupwise DISCOVER test.