mdvtools.mdvproject

Module Contents

Classes

MDVProject

Functions

get_json(file)

save_json(file, data)

get_subgroup_bytes(grp, index[, sparse])

add_column_to_group(col, data, group, length)

get_column_info(columns, dataframe, supplied_columns_only)

create_bed_gz_file(infile, outfile)

get_random_string([length])

Attributes

datatype_mappings

numpy_dtypes

mdvtools.mdvproject.datatype_mappings[source]
mdvtools.mdvproject.numpy_dtypes[source]
class mdvtools.mdvproject.MDVProject(dir, delete_existing=False)[source]
property datasources[source]
property views[source]
property state[source]
set_editable(edit)[source]
lock(type='read')[source]
get_column_metadata(datasource, column)[source]
set_column_metadata(datasource, column, parameter, value)[source]
get_datasource_as_dataframe(datasource)[source]
check_columns_exist(datasource, columns)[source]
set_interactions(interaction_ds, parent_ds, pivot_column='sample_id', parent_column='annotation', is_single_region=True, interaction_columns=['Cell Type 1', 'Cell Type 2'], default_parameter='Cross PCF gr20', node_size='cell 1 number', add_view=True)[source]
get_datasource_metadata(name)[source]
set_datasource_metadata(ds)[source]
_get_h5_handle(read_only=False)[source]
get_column(datasource, column, raw=False)[source]
set_column_with_raw_data(datasource, column, raw_data)[source]

Adds or updates a column with raw data :param datasource: The name of the datasource. :type datasource: str :param column: The complete metadata for the column :type column: dict :param raw_data: The raw binary data for the column :type raw_data: list|array

set_column(datasource, column, data)[source]

Adds (or replaces an existing column) with the data supplied

Parameters:
  • datasource (str) – The name of the datasource.

  • column (str|dict) – metadata for the column. Can be a string with the column’s name, although datatype should also be included as the inferred datatype is not always correct

  • raw_data (list|array) – Anything that can be converted into a pandas Series

  • order (The data should be in the correct) –

remove_column(datasource, column)[source]

Removes the specified column

Parameters:
  • datasource (str) – The name of the data source.

  • column (str) – The id (field) of the column.

add_annotations(datasource, data, separator='\t', missing_value='ND', columns=None, supplied_columns_only=False)[source]

Adds annotations based on an existing column

Parameters:
  • datasource (str) – The name of the data source.

  • data (dataframe|str) – Either a pandas dataframe or a text file. The first column should be the ‘index’ column and match a column in the datasource. The other columns should contain the annotations to add.

  • separator (str,optional) – The delimiter if a text file is supplied (tab by default)

  • missing_value (str,optional) – The value to put if the index value is missing in the input data. Default is ‘ND’

set_column_group(datasource, groupname, columns)[source]

Adds (or changes) a column group

Parameters:
  • datasource (string) – The name of the datasource

  • groupname (string) – The name of the column group

  • columns (list) – The field names of columns in the group. If None, then the column group will be removed

delete_datasource(name, delete_views=True)[source]
add_genome_browser(datasource, parameters=['chr', 'start', 'end'], name=None)[source]
add_datasource(name, dataframe, columns=None, supplied_columns_only=False, replace_data=False, add_to_view='default', separator='\t')[source]

Adds a pandas dataframe to the project. Each column’s datatype, will be deduced by the data it contains, but this is not always accurate. Hence, you can supply a list of column metadata, which will override the names/types deduced from the dataframe.

Parameters:
  • name (string) – The name of datasource

  • dataframe (dataframe|str) – Either a pandas dataframe or the path of a text file

  • columns (list, optional) – A list of objects containing the column name and datatype. e.g. [{“name”:”column_1”,”datatype”:”double”},]. If you want the column to have a different label, the object requires a field (the column name in the dataframe) and a name (the label seen by the user) e.g. {“field”:”column_1”,”datatype”:”double”,”name”:”My Column 1”}

  • supplied_columns_only (bool, optional) – If True, only the the subset of columns in the columns argument will be added to the datasource. Default is False

  • replace_data (bool, optional) – If True, the existing datasource will be overwritten, Default is False, in which case, trying to add a datasource which already exists, will throw an error.

  • add_to_view (string, optional) – The datasource will be added to the specified view. The view will be created if it does not exist. The default is ‘default’. If None, then it will not be added to a view.

  • separator (str, optional) – If a path to text file is supplied, then this should be the file’s delimiter. Defaults to a tab.

add_rows_as_columns_subgroup(row_ds, col_ds, stub, data, name=None, label=None, sparse=False)[source]
serve(**kwargs)[source]
get_configs()[source]
convert_to_static_page(outdir, include_sab_headers=True)[source]
save_state(state)[source]
add_image_set(datasource, setname, column, folder, type='png')[source]

Adds a set of images to a datasource. The images should be in a folder, with the same name as the column :param datasource: The name of the datasource. :type datasource: str :param column: The name of the column. :type column: str :param folder: The path to the folder containing the images. :type folder: str

get_view(view)[source]
set_view(name, view, make_default=False)[source]
convert_data_to_binary(outdir=None)[source]
get_byte_data(columns, group)[source]
set_region_data(datasource, data, region_field='sample_id', default_color='annotations', position_fields=['x', 'y'], scale_unit='um', scale=1)[source]
add_region_images(datasource, data)[source]
add_viv_viewer(datasource, default_channels)[source]
add_viv_images(datasource, data)[source]
mdvtools.mdvproject.get_json(file)[source]
mdvtools.mdvproject.save_json(file, data)[source]
mdvtools.mdvproject.get_subgroup_bytes(grp, index, sparse=False)[source]
mdvtools.mdvproject.add_column_to_group(col, data, group, length)[source]
mdvtools.mdvproject.get_column_info(columns, dataframe, supplied_columns_only)[source]
mdvtools.mdvproject.create_bed_gz_file(infile, outfile)[source]
mdvtools.mdvproject.get_random_string(length=6)[source]