SckanCompare Class
A package for retrieving and visualizing data contained in SCKAN (e.g., across species, relationship to spinal segments) to highlight similarities and differences in neuronal pathways
License: Apache License 2.0
- class sckan_compare.SckanCompare(endpoint='https://blazegraph.scicrunch.io/blazegraph/sparql', max_cache_days=7)
Bases:
object
Base class for accessing functionality
- execute_query(query_string, species=None, cached=True)
Execute a SPARQL query and return the result.
- Parameters:
query_string (str) – The SPARQL query string to execute.
species (str, optional) – The species to consider in the query, if applicable.
cached (bool, optional) – Whether to use cached data if available. Defaults to False.
- Returns:
The query result.
- Return type:
list
- get_filtered_dataframe(result, species=None, filter_column=None, filter_value=None)
Create a filtered DataFrame from a query result. Replaces all synonyms for species and regions with unique labels, followed by the deletion of duplicate rows.
- Parameters:
data (list) – The query result.
species (str) – The species for which the data is provided.
filter_column (str, optional) – The column to be filtered.
filter_value (str, optional) – The value to be used for filtering column.
- Returns:
The filtered DataFrame.
- Return type:
pandas.DataFrame
- get_valid_phenotypes()
Retrieve a list of valid phenotypes from the data source.
- Returns:
Dict with valid phenotypes URIs as keys and corresponding labels as values.
- Return type:
dict
- get_valid_phenotypes_circuit_role()
Retrieve a list of valid phenotypes with circuit role from the data source.
- Returns:
Dict with valid phenotypes URIs as keys and corresponding labels as values.
- Return type:
dict
- get_valid_regions_specify_species(species, region=None)
Retrieve a list of valid regions for a specific species from the data source.
- Parameters:
species (str) – The species for which to retrieve valid regions.
region (str, optional) – The region for which to retrieve valid regions. Valid values are: A, B, C or None. Defaults to None and returns all regions.
- Returns:
Dict of valid region URIs as keys and corresponding labels as values
- Return type:
dict
- get_valid_species()
Retrieve a list of valid species from the data source.
- Returns:
Dict with valid species URIs as keys and corresponding labels as values.
- Return type:
dict
- plot_dataframe_anatomy_vis(df, species=None, region_A=None, region_B=None, region_C=None)
Plot anatomical connectivity map based on a DataFrame.
- Parameters:
df (pandas.DataFrame) – The DataFrame containing connectivity information.
species (str, optional) – The species for visualization.
region_A (str, optional) – The source region for filtering.
region_B (str, optional) – The target region for filtering.
region_C (str, optional) – The intermediate region for filtering.
- Returns:
The Plotly figure widget.
- Return type:
go.FigureWidget
- plot_dataframe_block_vis(df, region_A=None, region_B=None)
Plot anatomical connectivity map based on a DataFrame.
- Parameters:
df (pandas.DataFrame) – The DataFrame containing connectivity information.
species (str, optional) – The species for visualization.
region_A (str, optional) – The source region for filtering.
region_B (str, optional) – The target region for filtering.
- Returns:
The Plotly figure widget.
- Return type:
go.FigureWidget
- replace_region_synonyms_dataframe(df, species)
Replace region synonyms in a DataFrame with unique labels.
e.g. ‘ovary’ : http://purl.obolibrary.org/obo/UBERON_0000992 has several synonyms, such as ‘animal ovary’, ‘female gonad’, etc. This method is used to map these synonyms to the parent label.
- Parameters:
df (pandas.DataFrame) – The DataFrame containing region information.
- Returns:
The DataFrame with replaced region synonyms.
- Return type:
pandas.DataFrame
- replace_species_synonyms_dataframe(df)
Replace species synonyms in a DataFrame with unique labels.
e.g. ‘Rattus norvegicus’ : http://purl.obolibrary.org/obo/NCBITaxon_10116 has several synonyms, such as ‘brown rat’, ‘Norway rat’, ‘rats’, ‘rat’. This method is used to map these synonyms to the parent label.
- Parameters:
df (pandas.DataFrame) – The DataFrame containing species information.
- Returns:
The DataFrame with replaced species synonyms.
- Return type:
pandas.DataFrame