generate_contin_table_with_clustered_AE

generate_contin_table_with_clustered_AE#

MDDC.utils.generate_contin_table_with_clustered_AE(row_marginal, column_marginal, signal_mat, contin_table=None, cluster_idx=None, n=100, rho=None, n_jobs=-1, seed=None)#

Generate simulated contingency tables with optional incorporation of adverse event correlation within clusters.

This function generates multiple simulated contingency tables based on the input row and column marginals, or contin_table, signal strength matrix (signal_mat), and cluster indices (cluster_idx). It incorporates adverse event correlation within each cluster according to the specified correlation parameter (rho).

Parameters:#

row_marginallist, np.ndarray, None

Marginal sums for the rows of the contingency table.

column_marginallist, np.ndarray, None

Marginal sums for the columns of the contingency table.

signal_matnumpy.ndarray, pandas.DataFrame

A data matrix of the same dimensions as contin_table, where entries represent signal strength. Values should be greater than or equal to 1, where 1 indicates no signal and values greater than 1 indicate the presence of a signal.

contin_tablenumpy.ndarray, pandas.DataFrame, default=None

A data matrix representing an I x J contingency table with row (adverse event) and column (drug) names. The row and column marginals of this table are used to generate the simulated data. It is advisable to check the input contingency table using the function check_and_fix_contin_table() before using this function.

cluster_idxnumpy.ndarray, list, pd.DataFrame

An array indicating the cluster index for each row in the contin_table. Clusters can be represented by names or numerical indices.

nint, optional, default=100

The number of simulated contingency tables to generate.

rhofloat, optional, numpy.ndarray, default=None
  • If a float or int, rho represents the correlation value to be used between elements within each cluster specified by cluster_idx.

  • If a numpy.ndarray, rho must be a square matrix with dimensions equal to the number of rows in contin_table. In this case the cluster_idx is not used.

  • If None, a covariance matrix is generated based on the correlation coefficients of contin_table.

n_jobsint, optional, default=-1

n_jobs specifies the maximum number of concurrently running workers. If 1 is given, no joblib parallelism is used at all, which is useful for debugging. For more information on joblib n_jobs refer to - https://joblib.readthedocs.io/en/latest/generated/joblib.Parallel.html.

seedint, optional, default=None

Random seed for reproducibility of the simulation.

Returns:#

simulated tableslist of numpy.ndarray

A list containing the simulated contingency tables.