utilities
- pyrnaither.utils.utilities.closest_to_zero(vec)[source]
Returns the value in the input vector that is closest to zero.
- Return type:
float- Parameters:
vec (List[float] | ndarray)
- Args:
vec: Input vector.
- Returns:
Value in the input vector that is closest to zero.
- pyrnaither.utils.utilities.create_subset(dataset, list_ids, equal_to)[source]
Creates a subset of the dataset where the list_ids column matches the equal_to value.
- Return type:
DataFrame- Parameters:
dataset (DataFrame)
list_ids (Series)
equal_to (str)
- Args:
dataset: DataFrame to subset. list_ids: Series of IDs to match. equal_to: Value to match in list_ids.
- Returns:
Subset of the dataset where list_ids matches equal_to.
- pyrnaither.utils.utilities.divide_channels(ch1, ch2)[source]
Returns the element-wise division of ch1 by ch2.
- Return type:
ndarray- Parameters:
ch1 (ndarray)
ch2 (ndarray)
- Args:
ch1: First channel. ch2: Second channel.
- Returns:
Element-wise division of ch1 by ch2.
- pyrnaither.utils.utilities.erase_dataset_column(dataset, colname)[source]
Erases the column with the given name from the dataset.
- Return type:
DataFrame- Parameters:
dataset (DataFrame)
colname (str)
- Args:
dataset: DataFrame to erase column from. colname: Name of the column to erase.
- Returns:
DataFrame with the column erased.
- pyrnaither.utils.utilities.find_replicates(dataset, which_col, replicate_id)[source]
Returns the indices of the dataset where the which_col column matches the replicate_id value.
- Return type:
List[int]- Parameters:
dataset (DataFrame)
which_col (str)
replicate_id (str)
- Args:
dataset: DataFrame to search. which_col: Column name to match. replicate_id: Value to match in which_col.
- Returns:
List of indices where which_col matches replicate_id.
- pyrnaither.utils.utilities.furthest_from_zero(vec)[source]
Returns the value in the input vector that is furthest from zero.
- Return type:
float- Parameters:
vec (List[float] | ndarray)
- Args:
vec: Input vector.
- Returns:
Value in the input vector that is furthest from zero.
- pyrnaither.utils.utilities.generate_replicate_mat(data, min_nb_reps, index_or_int, col4val, col4anno)[source]
Generates a replicate matrix from the given data.
- Return type:
Tuple[ndarray,List[int],List[int]]- Parameters:
data (DataFrame)
min_nb_reps (int)
index_or_int (str)
col4val (str)
col4anno (str)
- Args:
data: DataFrame containing at least columns [col4val, col4anno]. min_nb_reps: Minimum number of replicates required to keep an ID. index_or_int: “Index” to return row indices, “Intensities” to return values. col4val: name of the intensity column to fetch when index_or_int=”Intensities”. col4anno: name of the annotation column grouping replicates.
- Returns:
- replicate_matrix: 2D numpy array of shape (n_items, max_replicates), filled with
indices or values, using np.nan where missing.
index_pos_controls: list of row indices in replicate_matrix corresponding to positive controls. index_neg_controls: list of row indices in replicate_matrix corresponding to negative controls.
- pyrnaither.utils.utilities.generate_replicate_matrix_no_filter(data, min_nb_reps, index_or_int, col4val, col4anno)[source]
Build a replicate matrix without filtering.
- Return type:
Tuple[ndarray,List[int],List[int]]- Parameters:
data (DataFrame)
min_nb_reps (int)
index_or_int (str)
col4val (str)
col4anno (str)
- Args:
- data: DataFrame containing at least columns for annotation (col4anno),
SpotType, and intensity column (col4val).
min_nb_reps: minimum number of replicates required to keep an ID. index_or_int: “Index” to return row indices, “Intensities” to return values. col4val: name of the intensity column to fetch when index_or_int=”Intensities”. col4anno: name of the annotation column grouping replicates.
- Returns:
- replicate_matrix: 2D numpy array of shape (n_items, max_replicates), filled with
indices or values, using np.nan where missing.
index_pos_controls: list of row indices in replicate_matrix corresponding to positive controls. index_neg_controls: list of row indices in replicate_matrix corresponding to negative controls.
- pyrnaither.utils.utilities.index_subset(list_ids, equal_to)[source]
Returns the indices of the list_ids where the value matches equal_to.
- Return type:
List[int]- Parameters:
list_ids (Series)
equal_to (str)
- Args:
list_ids: Series of IDs to search. equal_to: Value to match in list_ids.
- Returns:
List of indices where list_ids matches equal_to.
- pyrnaither.utils.utilities.order_gene_ids(dataset, id_col)[source]
Orders the dataset by the id_col column and returns a new DataFrame with the indices reset.
- Return type:
DataFrame- Parameters:
dataset (DataFrame)
id_col (str)
- Args:
dataset: DataFrame to order. id_col: Column name to order by.
- Returns:
New DataFrame with the indices reset after ordering by id_col.
- pyrnaither.utils.utilities.rms(vec)[source]
Returns the root mean square of the input vector.
- Return type:
float- Parameters:
vec (List[float] | ndarray)
- Args:
vec: Input vector.
- Returns:
Root mean square of the input vector.
- pyrnaither.utils.utilities.sum_channels(header, dataset, fun_name, colname4ch1, colname4ch2)[source]
Sums the values of two channels in the dataset.
- Return type:
Tuple[List[str],DataFrame]- Parameters:
header (List[str])
dataset (DataFrame)
fun_name (Callable)
colname4ch1 (str)
colname4ch2 (str)
- Args:
header: The header of the dataset. dataset: The dataset to perform the sum on. fun_name: The function to use for the sum. colname4ch1: The name of the first channel. colname4ch2: The name of the second channel.
- Returns:
A tuple containing the updated header and dataset.
- pyrnaither.utils.utilities.summarize_reps(data, fun_sum, col4val, col4anno, cols2del)[source]
Summarizes the replicates in the given data.
- Return type:
DataFrame- Parameters:
data (DataFrame)
fun_sum (Callable)
col4val (List[str])
col4anno (str)
cols2del (List[str])
- Args:
data: DataFrame containing at least columns [col4val, col4anno]. fun_sum: Function to use for summarization. col4val: name of the column to summarize. col4anno: name of the annotation column grouping replicates. cols2del: list of columns to delete from the data.
- Returns:
DataFrame with the replicates summarized.