vfb_connect package

Subpackages

Submodules

vfb_connect.cross_server_tools module

class vfb_connect.cross_server_tools.VfbConnect(neo_endpoint='http://pdb.virtualflybrain.org', neo_credentials=('neo4j', 'vfb'), owlery_endpoint='http://owl.virtualflybrain.org/kbs/vfb/', lookup_prefixes=('FBbt', 'VFBexp', 'VFBext'))[source]

Bases: object

API wrapper class. By default this wraps connections to the more basal API endpoints (OWL, Neo4j).

Top level methods combined semantic queries that range across VFB content with neo4j queries, returning detailed metadata about anatomical classes and individuals that fulfill these queries.

Methods allowing direct queries cypher queries of the production Neo4j are available under nc

Methods for querying Neo4j with arbitrary lists of identifiers to return rich metadata or mappings to external IDs are available under neo_query_wrapper.

Direct access OWL queries, returning identifiers only, are available via methods under oc

Example semantic queries (OWL class expressions). Note quoting scheme (outer + single quotes for entities).

“‘GABAergic neuron’” “‘GABAeric neuron’ that ‘overlaps’ some ‘antennal lobe’”

get_connected_neurons_by_type(upstream_type, downstream_type, weight, query_by_label=True, return_dataframe=True)[source]

Get all synaptic connections between individual neurons of upstream_type and downstream_type where synapse count >= weight. Warning: Does not support Class Expressions.

Parm upstream_type:

The upstream neuron type (e.g. ‘GABAeric neuron’).

Parameters:
  • downstream_type – The upstream neuron type (e.g. ‘Descending neuron’).

  • query_by_label – specify neuron type by label if True (default) or by short_form id if False

  • return_dataframe – Returns pandas dataframe if true, otherwise returns list of dicts.

get_gene_function_filters()[source]

Get list of all gene function labels.

Returns:

List of unique gene function labels in alphabetical order.

Return type:

list

get_images_by_type(class_expression, template, image_folder, image_type='swc', query_by_label=True, direct=False, stomp=False)[source]

Download all images of individuals specified by a class expression, e.g. all images of the nodulus or of MBON01.

Parameters:
  • class_expression – A valid OWL class expression, e.g. the name or symbol of a type of neuron (MBON01)

  • template – template name

  • image_folder – folder to save image files & manifest to.

  • image_type – image type (file extension)

  • stomp – Overwrite image_folder if already exists.

Returns:

Manifest as Pandas DataFrame

get_instances(class_expression, query_by_label=True, summary=False)[source]

Generate JSON report of all instances of class_expression. Instances are specific examples of a type/class, e.g. a neuron of type DA1 adPN from the FAFB_catmaid database.

Parameters:
  • class_expression – A valid OWL class expression, e.g. the name of a class.

  • query_by_label – Optional. If false, class_expression takes IDs instead of labels Default True

  • summary – Optional. Returns summary reports if true. Default False

Returns:

Returns a list of terms as nested python data structures following VFB_json or a summary_report_json

Return type:

list of VFB_json or summary_report_json

get_instances_by_dataset(dataset, summary=False)[source]

Get JSON report of all individuals in a dataset

Parameters:
  • dataset – dataset ID

  • summary – Optional. Returns summary reports if true. Default False

Returns:

Returns a list of terms as nested python data structures following VFB_json or a summary_report_json

Return type:

list of VFB_json or summary_report_json

get_neurons_downstream_of(neuron, weight, classification=None, query_by_label=True, return_dataframe=True)[source]

Get all neurons downstream of individual neuron

Parameters:
  • neuron – the name or id of a particular neuron (dependent on query_by_label setting)

  • weight – limit returned neurons to those with connected by >= weight synapses

  • query_by_label – query neuron may be specified with a label if true

  • return_dataframe – Returns pandas dataframe if true, otherwise returns list of dicts.

Classification:

optionally specify classification of downstream neuron using a class expression e.g. MBON

get_neurons_upstream_of(neuron, weight, classification=None, query_by_label=True, return_dataframe=True)[source]

“Get all neurons upstream of individual neuron

Parameters:
  • neuron – the name or id of a particular neuron (dependent on query_by_label setting)

  • weight – limit returned neurons to those with connected by >= weight synapses

  • query_by_label – query neuron may be specified with a label if true

  • return_dataframe – Returns pandas dataframe if true, otherwise returns list of dicts.

Classification:

optionally specify classification of upstream neuron using a class expression e.g. MBON

get_similar_neurons(neuron, similarity_score='NBLAST_score', return_dataframe=True)[source]

Get JSON report of individual neurons similar to input neuron

Parameters:
  • neuron

  • similarity_score – Optionally specify similarity score to chose

  • return_dataframe – Returns pandas dataframe if true, otherwise returns list of dicts.

Returns:

list of similar neurons (id, label, tags, source (db) id, accession_in_source) + similarity score.

Return type:

pandas.DataFrame or list of dicts

get_subclasses(class_expression, query_by_label=True, direct=False, summary=False)[source]

Generate JSON report of all subclasses of class_expression.

Parameters:
  • class_expression – A valid OWL class expression, e.g. the name of a class.

  • query_by_label – Optional. If false, class_expression takes IDs instead of labels Default True

  • direct – Return direct subclasses only. Default False

  • summary – Optional. Returns summary reports if true. Default False

Returns:

Returns a list of terms as nested python data structures following VFB_json or a summary_report_json

Return type:

list of VFB_json or summary_report_json

get_superclasses(class_expression, query_by_label=True, direct=False, summary=False)[source]

Generate JSON report of all superclasses of class_expression.

Parameters:
  • class_expression – A valid OWL class expression, e.g. the name of a class.

  • query_by_label – Optional. If false, class_expression takes IDs instead of labels Default True

  • direct – Return direct superclass only. Default False

  • summary – Optional. Returns summary reports if true. Default False

Returns:

Returns a list of terms as nested python data structures following VFB_json or a summary_report_json

Return type:

list of VFB_json or summary_report_json

get_terms_by_region(region, cells_only=False, verbose=False, query_by_label=True, summary=False)[source]

Generate TermInfo reports for all terms relevant to annotating some specific region, optionally limited to cells.

Parameters:
  • region – The name (rdfs:label) of brain region (or CURIE style ID if query_by_label is False)

  • cells_only – Optional. Limits query to cell type if True. Defaults to False

  • verbose – Optional.

  • query_by_label – Optional (see region). Default True

  • summary – Optional. Returns summary reports if true. Default False

Returns:

Returns a list of terms as nested python data structures following VFB_json or a summary_report_json

Return type:

list of VFB_json or summary_report_json

get_transcriptomic_profile(cell_type, gene_type=False, return_dataframe=True)[source]

Get gene expression data for a given cell_type.

Returns a DataFrame of gene expression data for clusters of cells annotated as cell_type (or subtypes). Can optionally restrict to a gene_type - these can be retrieved by running get_gene_function_filters. If no data is found, returns False.

Parameters:
  • cell_type – The ID, name or symbol of a class in the Drosophila Anatomy Ontology (FBbt).

  • gene_type – Optional. A gene function label - these can be retrieved by running get_gene_function_filters().

Returns:

DataFrame with gene expression data for clusters of cells annotated as cell_type (or subtypes).

Return type:

DataFrame

Takes a list of VFB IDs (short_forms) and the name (label) of a template. Returns a link to VFB loading all available images of neurons on that template.

Parameters:

short_forms (iter) – A list (or other iterable) of VFB short_form IDs for individuals with images

Returns:

A url for viewing images and metadata for specified individuals on VFB.

lookup_id(key, return_short_form=True)[source]
vfb_connect.cross_server_tools.dequote(string)[source]
vfb_connect.cross_server_tools.gen_short_form(iri)[source]

Generate short_form (string) from an iri string iri: An iri string

vfb_connect.default_servers module

vfb_connect.default_servers.get_default_servers()[source]

Module contents