GSForge.utils.R_interface module¶
This module contains functions for preparing data for transfer to and from the R programming language.
Such functionality is powered by the rpy2 library.
No conversion function is needed for preparing labels, as one can use the builtin pandas.DataFrame
function to_dataframe.:
label_df = labels.to_dataframe()
- GSForge.utils.R_interface.Py_counts_to_R(counts: xarray.core.dataarray.DataArray)¶
Prepare a count
xarray.DataArrayas apandas.DataFramefor transfer to the R programming language.This function transposes the data to have genes as rows and samples as columns. It then converts to a
pandas.DataFrameand removes extraneous index levels.The inverse of this function is
R_counts_to_Py_counts.- Parameters
counts – An
xr.DataArraycount matrix.- Returns count_df
A
pandas.DataFrameready to transfer to an R environment.
- GSForge.utils.R_interface.R_counts_to_Py(r_count_array, original_count_array)¶
Prepares a
numpyarray (count matrix) for use inGSForge.This function transposes the data (so that it has samples as rows and genes as columns).
Inverts the conversion provided by
Py_counts_to_R.- Parameters
r_count_array – A
numpyarray of count values. Presumed to be oriented with genes as rows, and samples as columns.original_count_array – A copy of the original count array from which coordinates will be drawn.
- Returns
An
xarray.DataArrayof the count values.
- GSForge.utils.R_interface.Py_labels_to_R(label_ds)¶