liana.rs.translate_resource#
- liana.rs.translate_resource(resource, map_df, columns=None, replace=True, one_to_many=1)#
Generate orthologs for multiple columns in a DataFrame.
- Parameters:
- resource
DataFrame Input DataFrame.
- map_df
DataFrame DataFrame with orthology mappings, where the first column is the source and the second column is the target for mapping.
- columns
list[str] |None(default:None) List of column names to translate.
- **kwargs
Additional arguments for
liana.rs.translate_column.
- resource
- Return type:
- Returns:
Resulting DataFrame with translated columns.
Examples
Translates the
'ligand'and'receptor'columns in one go. In practicemap_dfcomes fromliana.rs.get_hcop_orthologs(); interactions whose partners have no ortholog are dropped:>>> import pandas as pd >>> import liana as li >>> resource = li.rs.select_resource("consensus").head(3) >>> map_df = pd.DataFrame( ... {"source": ["LGALS9", "PTPRC", "MET", "CD44"], "target": ["Lgals9", "Ptprc", "Met", "Cd44"]} ... ) >>> li.rs.translate_resource(resource, map_df) ligand receptor 0 Lgals9 Ptprc 1 Lgals9 Met 2 Lgals9 Cd44