unravel.allen_institute.abca.merfish.merfish_filter module#

Use abca_merfish_filter or mf_filter from UNRAVEL to filter ABCA MERFISH cells based on columns and values in the cell metadata. It integrates the filtering with the generation of exp_df and allows optional export of filtered data or the generation of updated 3D images.

Note

  • The input CSV may be previously filtered (e.g., abca_merfish_filter_by_mask) or it may be the full cell metadata (cell_metadata.csv).

  • Columns to filter by: parcellation_substructure (default)

  • Values to filter by: e.g., ACB

  • Regional columns can be printed with cols -i <ABCA_root>/metadata/Allen-CCF-2020/20230630/views/parcellation_to_parcellation_term_membership_acronym.csv

  • Regional values can be printed with vals -i <ABCA_root>/metadata/Allen-CCF-2020/20230630/views/parcellation_to_parcellation_term_membership_acronym.csv -c substructure

  • parcellation_ is prepended to the regional column names in the cell metadata, so for example substructure becomes parcellation_substructure

Outputs:
  • Filtered cell metadata CSV file (default: <input_stem>_filtered[_<first_value>][_neurons].csv)

  • With --all_values, one CSV per unique value for each specified column.

Next steps:
  • Use the filtered cell metadata to examine cell type prevalence or gene expression

  • For cell type proportions like in the MapMySections data challenge, use mms_cell_type_proportions to calculate proportions for a given ontological level (e.g., subclass)

  • Then use mms_cell_type_proportions_concat to concatenate multiple CSVs into one file (one row per input file)

  • To visualize cell type proportions, use abca_sunburst to make a CSV for sunburst plotting

  • For looking at gene expression, load the filtered cell metadata and join it with the expression data for the gene(s) of interest (abca_merfish_join_expression)

Usage:#

abca_merfish_filter -b path/base_dir [–columns] [–values] [-o path/output.csv] [-n] [-v] abca_merfish_filter -b path/base_dir -a [-c column …] [-o path/output_dir] [-w workers] [-n] [-v]

unravel.allen_institute.abca.merfish.merfish_filter.parse_args()[source]#
unravel.allen_institute.abca.merfish.merfish_filter.sanitize_filename(value)[source]#

Convert a column value to a filesystem-safe string.

unravel.allen_institute.abca.merfish.merfish_filter.save_filtered_value(df, indices, value, output_path)[source]#

Save rows corresponding to one column value.

unravel.allen_institute.abca.merfish.merfish_filter.filter_all_values(df, columns, output_dir, stem, neurons=False, workers=1)[source]#

Write one CSV for every unique value in each specified column.

unravel.allen_institute.abca.merfish.merfish_filter.filter_dataframe(df, columns, values)[source]#

Filter a DataFrame by columns and values.

Parameters:
  • df (pd.DataFrame) – The DataFrame to filter.

  • columns (list of str) – Columns to filter by.

  • values (list of str) – Values (or comma-separated groups of values) to include across all columns.

Returns:

filtered_df – The filtered DataFrame.

Return type:

pd.DataFrame

unravel.allen_institute.abca.merfish.merfish_filter.main()[source]#