pyrnaither.stats.stattests module
- pyrnaither.stats.stattests.compare_hits(hit_vec1, hit_vec2, names1, names2)[source]
Returns the list of annotation names where both hit vectors agree on a hit (1). Raises if inputs are mismatched.
- Return type:
List[str]- Parameters:
hit_vec1 (Sequence[int])
hit_vec2 (Sequence[int])
names1 (Sequence[str])
names2 (Sequence[str])
- Args:
hit_vec1: First hit vector. hit_vec2: Second hit vector. names1: First set of annotation names. names2: Second set of annotation names.
- Returns:
List of annotation names where both hit vectors agree on a hit (1).
- pyrnaither.stats.stattests.hit_selection_pval(dataset, p_val_vec, col4val, col4sel, thresh, col4anno, file4hits)[source]
Select hits based on p-value threshold.
- Return type:
Tuple[DataFrame,Series,DataFrame,float]- Parameters:
dataset (DataFrame)
p_val_vec (Series)
col4val (str)
col4sel (str)
thresh (float)
col4anno (str)
file4hits (str)
- Args:
dataset: DataFrame containing at least columns [col4val, col4anno]. p_val_vec: Series of p-values indexed by feature/annotation. col4val: Column name for intensity values. col4sel: Column name for selection. thresh: P-value threshold for selection. col4anno: Column name for annotation. file4hits: File name for hits output.
- Returns:
Tuple of (dataset, hit_vector, replica_matrix, used_threshold)
- pyrnaither.stats.stattests.hit_selection_zscore(dataset, col4zscore, col4sel, thresh, flag, flag2, col4anno, sum_func, file4hits)[source]
Select hits based on Z-score ranking or threshold.
- Return type:
Tuple[DataFrame,Series]- Parameters:
dataset (DataFrame)
col4zscore (str)
col4sel (str)
thresh (int)
flag (int)
flag2 (int)
col4anno (str)
sum_func (Callable[[...], float])
file4hits (str)
- Args:
dataset: DataFrame containing at least columns [col4zscore, col4anno]. col4zscore: Column name for Z-score. col4sel: Column name for selection. thresh: Z-score threshold for selection. flag: 1 for ‘l’ (lower), else ‘g’ (greater). flag2: 1 for ‘l’ (lower), else ‘g’ (greater). col4anno: Column name for annotation. sum_func: Function to calculate sum of replicates. file4hits: File name for hits output.
- Returns:
Tuple of (dataset, hit_vector)
- pyrnaither.stats.stattests.hit_selection_zscore_pval(dataset, p_val_vec, col4zscore, col4sel, thresh, thresh2, flag2, col4anno, sum_func, file4hits)[source]
Combined Z-score and p-value hit selection. Returns (dataset, hit_vector, used_thresh_z, used_thresh_p).
- Return type:
Tuple[DataFrame,Series,float,float]- Parameters:
dataset (DataFrame)
p_val_vec (Series)
col4zscore (str)
col4sel (str)
thresh (float)
thresh2 (float)
flag2 (int)
col4anno (str)
sum_func (Callable[[...], float])
file4hits (str)
- Args:
dataset: DataFrame containing at least columns [col4zscore, col4anno]. p_val_vec: Series of p-values indexed by feature/annotation. col4zscore: Column name for Z-score. col4sel: Column name for selection. thresh: Z-score threshold for selection. thresh2: P-value threshold for selection. flag2: 1 for ‘l’ (lower), else ‘g’ (greater). col4anno: Column name for annotation. sum_func: Function to calculate sum of replicates. file4hits: File name for hits output.
- Returns:
Tuple of (dataset, hit_vector, used_thresh_z, used_thresh_p).
- pyrnaither.stats.stattests.incorporate_pval_vec(dataset, p_val, col4anno, colname4pval)[source]
Add a new column colname4pval to dataset, mapping each row’s annotation (in col4anno) to the corresponding p-value.
- Return type:
DataFrame- Parameters:
dataset (DataFrame)
p_val (Series)
col4anno (str)
colname4pval (str)
- Args:
dataset: DataFrame to modify. p_val: Series of p-values indexed by annotation labels. col4anno: Column name for annotation grouping. colname4pval: Column name for p-value.
- Returns:
DataFrame with new p-value column.
- pyrnaither.stats.stattests.mann_whitney(dataset, args)[source]
Port of the R MannWhitney function to Python.
args = [testType, reference, col4val, col4anno] - testType: ‘two.sided’, ‘less’, or ‘greater’ - reference: numeric (for one-sample) or string (for two-sample) - col4val: column name for intensity values - col4anno: column name for annotation grouping
- Return type:
Tuple[Series,DataFrame,str,str]- Parameters:
dataset (DataFrame)
args (List[Any])
- Returns:
p_val: Series indexed by annotation labels new_dataset: DataFrame with new p-value column pval_colname: name of the p-value column method: ‘Mann-Whitney test’
- pyrnaither.stats.stattests.mult_test_adjust(p_val_vec, adjust_method)[source]
Adjust p-values for multiple testing.
- Return type:
Series- Parameters:
p_val_vec (Series)
adjust_method (str)
- Args:
p_val_vec: Series of p-values indexed by feature/annotation. adjust_method: correction method, e.g., ‘bonferroni’, ‘fdr_bh’, etc.
- Returns:
Series of adjusted p-values (same index).
- pyrnaither.stats.stattests.rank_product(dataset, args)[source]
Port of the R RankProduct function to Python via permutation-based test.
args = [permutations, flag, col4val, col4anno] - permutations: number of random permutations - flag: 1 for ‘l’ (lower), else ‘g’ (greater) - col4val: column name for intensity values - col4anno: column name for annotation grouping
- Return type:
Tuple[Series,DataFrame,str,str]- Parameters:
dataset (DataFrame)
args (List[Any])
- Returns:
p_val: Series indexed by annotation labels (estimated pfp) new_dataset: DataFrame with new p-value column pval_colname: name of the p-value column method: ‘Rank product test’
- pyrnaither.stats.stattests.spatial_distrib_hits(header, dataset, plot_title, col4hits, col4anno, show_plot)[source]
Wrapper for spatial distribution plotting of hits. Assumes a function spatial_distrib is defined elsewhere.
- Return type:
None- Parameters:
header (List[str])
dataset (DataFrame)
plot_title (str)
col4hits (str)
col4anno (str)
show_plot (bool)
- Args:
header: List of column names. dataset: DataFrame containing at least columns [col4hits, col4anno]. plot_title: Title for the plot. col4hits: Column name for hits. col4anno: Column name for annotation. show_plot: Whether to show the plot interactively.
- pyrnaither.stats.stattests.t_test(dataset, args)[source]
Port of the R Ttest function to Python.
args = [testType, reference, col4val, col4anno] - testType: ‘two.sided’, ‘less’, or ‘greater’ - reference: numeric (for one-sample) or string (for two-sample) - col4val: column name for intensity values - col4anno: column name for annotation grouping
- Return type:
Tuple[Series,DataFrame,str,str]- Parameters:
dataset (DataFrame)
args (List[Any])
- Returns:
p_val: Series indexed by annotation labels new_dataset: DataFrame with new p-value column pval_colname: name of the p-value column method: ‘t test’
- pyrnaither.stats.stattests.venn_diag(header, list_of_cols, list_of_names, plot_title, show_plot)[source]
Creates and saves a Venn diagram for 2 or 3 hit sets. Returns the base plot name.
- Return type:
str- Parameters:
header (List[str])
list_of_cols (List[Sequence[int]])
list_of_names (List[str])
plot_title (str)
show_plot (bool)
- Args:
header: List of column names. list_of_cols: List of columns for the hit sets. list_of_names: List of names for the hit sets. plot_title: Title for the plot. show_plot: Whether to show the plot interactively.
- Returns:
Base plot name.
- pyrnaither.stats.stattests.volcano_plot(header, dataset, col4plotx, col4ploty, col4anno, plot_title, sig_level, show_plot)[source]
Generates a volcano plot and saves PDF/PNG. Returns the base plot name.
- Return type:
str- Parameters:
header (List[str])
dataset (DataFrame)
col4plotx (str)
col4ploty (str)
col4anno (str)
plot_title (str)
sig_level (Sequence[float])
show_plot (bool)
- Args:
header: List of column names. dataset: DataFrame containing at least columns [col4plotx, col4ploty, col4anno]. col4plotx: Column name for x-axis. col4ploty: Column name for y-axis. col4anno: Column name for annotation. plot_title: Title for the plot. sig_level: Significance level for the plot. show_plot: Whether to show the plot interactively.
- Returns:
Base plot name.