mdvtools.conversions ==================== .. py:module:: mdvtools.conversions Functions --------- .. autoapisummary:: mdvtools.conversions.convert_scanpy_to_mdv mdvtools.conversions.convert_mudata_to_mdv mdvtools.conversions.convert_vcf_to_df mdvtools.conversions.compute_vcf_end mdvtools.conversions.convert_vcf_to_mdv mdvtools.conversions.create_regulamentary_project mdvtools.conversions._create_dt_heatmap mdvtools.conversions._add_dims Module Contents --------------- .. py:function:: convert_scanpy_to_mdv(folder: str, scanpy_object: scanpy.AnnData, max_dims: int = 3, delete_existing: bool = False, label: str = '') -> mdvtools.mdvproject.MDVProject Convert a Scanpy AnnData object to MDV (Multi-Dimensional Viewer) format. This function transforms single-cell RNA sequencing data from AnnData format into the MDV project structure, handling both cells and genes as separate datasources with their associated dimensionality reductions and metadata. :param folder: Path to the target MDV project folder :type folder: str :param scanpy_object: The AnnData object containing the single-cell data :type scanpy_object: AnnData :param max_dims: Maximum number of dimensions to include from dimensionality reductions. Defaults to 3. :type max_dims: int, optional :param delete_existing: Whether to delete existing project data. If False, merges with existing data. Defaults to False. :type delete_existing: bool, optional :param label: Prefix to add to datasource names and metadata columns when merging with existing data. Defaults to "". :type label: str, optional :returns: The configured MDV project object with the converted data :rtype: MDVProject .. rubric:: Notes Data Structure Creation: - Creates two main datasources: '{label}cells' and '{label}genes' - Preserves all cell metadata from scanpy_object.obs - Preserves all gene metadata from scanpy_object.var - Transfers dimension reductions from obsm/varm matrices - Links cells and genes through expression data - Adds gene expression scores as a subgroup View Handling: - If delete_existing=True: * Creates new default view with empty initial charts * Sets project as editable - If delete_existing=False: * Preserves existing views * Updates views with new datasources * Maintains panel widths and other view settings * Adds new datasources to each view's initialCharts Dimension Reduction: - Processes dimensionality reductions up to max_dims - Supports standard formats (e.g., PCA, UMAP, t-SNE) - Column names in the format: {reduction_name}_{dimension_number} :raises ValueError: If the provided AnnData object is invalid or missing required components :raises IOError: If there are issues with file operations in the target folder :raises Exception: For other unexpected errors during conversion .. py:function:: convert_mudata_to_mdv(folder: str, mudata_object: mudata.MuData, max_dims=3) -> mdvtools.mdvproject.MDVProject .. py:function:: convert_vcf_to_df(vcf_filename: str) -> pandas.DataFrame .. py:function:: compute_vcf_end(df: pandas.DataFrame) -> pandas.DataFrame Compute the end position of the variant determined from 'POS', 'REF' and 'ALT'. This is added as a column 'END' in the given DataFrame. .. py:function:: convert_vcf_to_mdv(folder: str, vcf_filename: str) -> mdvtools.mdvproject.MDVProject Converts a VCF file to an MDV project. The VCF file must be tab-delimited, with the header lines starting with "##" and column names in the line starting with "#CHROM". An 'END' column is derived, which is the end position of the variant determined from 'POS', 'REF' and 'ALT'. .. py:function:: create_regulamentary_project(folder, output: str, name: str, bigwig_folder='', bed_folder='', openchrome='DNase', openchrome_color='#eb9234', marks=['H3K4me1', 'H3K4me3', 'H3K27ac', 'CTCF'], mark_colors=['#349beb', '#3aeb34', '#c4c41f', '#ab321a'], genome='hg38') .. py:function:: _create_dt_heatmap(folder, project, mdv, marks) .. py:function:: _add_dims(table, dims, max_dims)