metaclean3.binning¶
Module Contents¶
Functions¶
|
Determine a relative time bin unit. |
|
Reduce a time bin size by a fraction and return the new time bin size and scale. |
|
Convert a dataset with timestamps into a flow dataframe. |
|
|
|
Bin the time channel values. |
-
metaclean3.binning.get_time_bin_unit(time_values: list | numpy.ndarray | pandas.Series, time_bin: str | int | float | None =
None, bin_size_temp: int =1000000, bin_no_max_temp: int =10)¶ Determine a relative time bin unit.
- Args:
time_values (list | numpy.ndarray | pandas.Series): Time channel values. time_bin (str | int | float | None, optional): The desired time bin
size, in seconds or milliseconds. Defaults to None.
- bin_size_temp (int, optional): Default bin frequency.
Defaults to 1000000.
bin_no_max_temp (int, optional): Maximum bin size. Defaults to 10.
- Returns:
str: Time bin unit.
-
metaclean3.binning.adjust_time_bin(time_bin: str, frac: float =
0.5, reduce: bool =True)¶ Reduce a time bin size by a fraction and return the new time bin size and scale.
- Args:
time_bin (str): The initial time bin size. frac (int, optional): The fraction to reduce the time bin size by.
Defaults to 2.
- Reduce (bool, optional): whether to reduce or increase time bin.
Defaults to True.
- Returns:
- tuple:
str: time_bin. str: time_unit.
-
metaclean3.binning.data_to_flow(time_values: numpy.ndarray | pandas.Series, min_bin: int =
2000, max_time: int =int(1000000000.0), min_time: int =1000)¶ Convert a dataset with timestamps into a flow dataframe.
- Args:
time_values (numpy.ndarray | pandas.Series): Time channel values. min_bin (int, optional): Minimum number of bins. Defaults to 2000. max_time (int, optional): Maximum time scale to use.
Defaults to 1e9 (1 second).
min_time (int, optional): Maximum time scale to use. Defaults to 1000.
- Returns:
- pandas.DataFrame: A flow dataframe with timestamped rows
and an ‘index’ column.
- metaclean3.binning._get_time_bin_while(flow_df: pandas.DataFrame, time_bin: str, reduce: bool)¶
-
metaclean3.binning.get_time_binned(time_values: numpy.ndarray | pandas.Series, time_bin: str =
'1S', time_step: float | None =None, min_bin_size: int =2000, max_bin_size: int =10000, min_events_per_bin: int =50)¶ Bin the time channel values.
- Args:
time_values (numpy.ndarray | pandas.Series): Time channel values. time_bin (str, optional): Time bin i.e. duration of each bin.
Defaults to ‘1S’.
- time_step (float | None, optional): Time step parameter from FCS file
e.g. meta.get(‘$TIMESTEP’). Defaults to None.
min_bin_size (int, optional): Minimum number of bins. Defaults to 2000. max_bin_size (int, optional): Maximum number of bins. Defaults to 10000. min_events_per_bin (int, optional): Minimum number of events per bin.
Defaults to 50.
- Returns:
- numpy.ndarray: A 1D numpy array with the same length as time_values
containing integer bin labels.