pegasusio/multimodal_data.py
def filter_data(self,
        select_singlets: Optional[bool] = False,
        remap_string: Optional[str] = None,
        subset_string: Optional[str] = None,
        min_genes: Optional[int] = None,
        max_genes: Optional[int] = None,
        min_umis: Optional[int] = None,
        max_umis: Optional[int] = None,
        mito_prefix: Optional[str] = None,
        percent_mito: Optional[float] = None,
        focus_list: Optional[Union[List[str], str]] = None,
        cache_passqc: Optional[bool] = False,
        uns_white_list: Optional[str] = None,
    ) -> None:
        """
        Filter each "rna" modality UnimodalData in the focus_list separately using the set filtration parameters. Then for all other UnimodalData objects, select only barcodes that are in the union of selected barcodes from previously filtered UnimodalData objects.
        If focus_list is None, focus_list = [self._selected]

        Parameters
        ----------
        select_singlets: ``bool``, optional, default ``False``
            If select only singlets.
        remap_string: ``str``, optional, default ``None``
            Remap singlet names using <remap_string>, where <remap_string> takes the format "new_name_i:old_name_1,old_name_2;new_name_ii:old_name_3;...". For example, if we hashed 5 libraries from 3 samples sample1_lib1, sample1_lib2, sample2_lib1, sample2_lib2 and sample3, we can remap them to 3 samples using this string: "sample1:sample1_lib1,sample1_lib2;sample2:sample2_lib1,sample2_lib2". In this way, the new singlet names will be in metadata field with key 'assignment', while the old names will be kept in metadata field with key 'assignment.orig'.
        subset_string: ``str``, optional, default ``None``
            If select singlets, only select singlets in the <subset_string>, which takes the format "name1,name2,...". Note that if --remap-singlets is specified, subsetting happens after remapping. For example, we can only select singlets from sampe 1 and 3 using "sample1,sample3".
        min_genes: ``int``, optional, default: None
            Only keep cells with at least ``min_genes`` genes.
        max_genes: ``int``, optional, default: None
            Only keep cells with less than ``max_genes`` genes.
        min_umis: ``int``, optional, default: None
            Only keep cells with at least ``min_umis`` UMIs.
        max_umis: ``int``, optional, default: None
            Only keep cells with less than ``max_umis`` UMIs.
        mito_prefix: ``str``, optional, default: None
            Prefix for mitochondrial genes. For example, GRCh38:MT-,mm10:mt-.
        percent_mito: ``float``, optional, default: None
            Only keep cells with percent mitochondrial genes less than ``percent_mito`` % of total counts. Only when both mito_prefix and percent_mito set, the mitochondrial filter will be triggered.
        focus_list: ``List[str]`` or ``str``, optional, default None
            Filter each UnimodalData with key in focus_list (and modality is 'rna') separately using the filtration criteria. If only one focus is provided, focus_list can be a string instead of a list.
        cache_passqc: ``bool``, optional, default: ``False``
            If True and "passed_qc" is in a UnimodalData object's obs field, use the cached "passed_qc" instead of recalculating it using 'calc_qc_filters'.
        uns_white_list: ``str``, optional, default: ``None``
            If not None, this is string representing a comma-separated list of uns keywords that should not be removed. In addition, 'genome' and 'modality' will not be removed. All other keys in uns will be removed. If None, do not remove any keyword from uns.
        """
        selected_barcodes = None

        if focus_list is None:
            focus_list = [self._selected]
        elif isinstance(focus_list, str):
            focus_list = [focus_list]
        focus_set = set(focus_list)

        unselected = []
        mito_dict = DictWithDefault(mito_prefix)
        for key, unidata in self.data.items():
            if (key in focus_set) and (unidata.get_modality() == "rna"):
                if ("passed_qc" not in unidata.obs) or (not cache_passqc):
                    calc_qc_filters(unidata,
                        select_singlets = select_singlets,
                        remap_string = remap_string,
                        subset_string = subset_string,
                        min_genes = min_genes,
                        max_genes = max_genes,
                        min_umis = min_umis,
                        max_umis = max_umis,
                        mito_prefix = mito_dict.get(unidata.get_genome()),
                        percent_mito = percent_mito)
                apply_qc_filters(unidata, uns_white_list=uns_white_list)
                selected_barcodes = unidata.obs_names if selected_barcodes is None else selected_barcodes.union(unidata.obs_names)
            else:
                unselected.append(unidata)

        if (selected_barcodes is not None) and len(unselected) > 0:
            for unidata in unselected:
                selected = unidata.obs_names.isin(selected_barcodes)
                prior_n = unidata.shape[0]
                unidata._inplace_subset_obs(selected)
                logger.info(f"After filtration, {unidata.shape[0]} out of {prior_n} cell barcodes are kept in UnimodalData object {unidata.get_uid()}.")

        Filter each "rna" modality UnimodalData in the focus_list separately using the set filtration parameters. Then for all other UnimodalData objects, select only barcodes that are in the union of selected barcodes from previously filtered UnimodalData objects.
        If focus_list is None, focus_list = [self._selected]

        Parameters
        ----------
        select_singlets: ``bool``, optional, default ``False``
            If select only singlets.
        remap_string: ``str``, optional, default ``None``
            Remap singlet names using <remap_string>, where <remap_string> takes the format "new_name_i:old_name_1,old_name_2;new_name_ii:old_name_3;...". For example, if we hashed 5 libraries from 3 samples sample1_lib1, sample1_lib2, sample2_lib1, sample2_lib2 and sample3, we can remap them to 3 samples using this string: "sample1:sample1_lib1,sample1_lib2;sample2:sample2_lib1,sample2_lib2". In this way, the new singlet names will be in metadata field with key 'assignment', while the old names will be kept in metadata field with key 'assignment.orig'.
        subset_string: ``str``, optional, default ``None``
            If select singlets, only select singlets in the <subset_string>, which takes the format "name1,name2,...". Note that if --remap-singlets is specified, subsetting happens after remapping. For example, we can only select singlets from sampe 1 and 3 using "sample1,sample3".
        min_genes: ``int``, optional, default: None
            Only keep cells with at least ``min_genes`` genes.
        max_genes: ``int``, optional, default: None
            Only keep cells with less than ``max_genes`` genes.
        min_umis: ``int``, optional, default: None
            Only keep cells with at least ``min_umis`` UMIs.
        max_umis: ``int``, optional, default: None
            Only keep cells with less than ``max_umis`` UMIs.
        mito_prefix: ``str``, optional, default: None
            Prefix for mitochondrial genes. For example, GRCh38:MT-,mm10:mt-.
        percent_mito: ``float``, optional, default: None
            Only keep cells with percent mitochondrial genes less than ``percent_mito`` % of total counts. Only when both mito_prefix and percent_mito set, the mitochondrial filter will be triggered.
        focus_list: ``List[str]`` or ``str``, optional, default None
            Filter each UnimodalData with key in focus_list (and modality is 'rna') separately using the filtration criteria. If only one focus is provided, focus_list can be a string instead of a list.
        cache_passqc: ``bool``, optional, default: ``False``
            If True and "passed_qc" is in a UnimodalData object's obs field, use the cached "passed_qc" instead of recalculating it using 'calc_qc_filters'.
        uns_white_list: ``str``, optional, default: ``None``
            If not None, this is string representing a comma-separated list of uns keywords that should not be removed. In addition, 'genome' and 'modality' will not be removed. All other keys in uns will be removed. If None, do not remove any keyword from uns.
        
Filter each "rna" modality UnimodalData in the focus_list separately using the set filtration parameters. Then for all other UnimodalData objects, select only barcodes that are in the union of selected barcodes from previously filtered UnimodalData objects.
If focus_list is None, focus_list = [self._selected]

Parameters


Filter each " rna " modality UnimodalData in the focus_list separately using the set filtration parameters . Then for all other UnimodalData objects select only barcodes that are in the union of selected barcodes from previously filtered UnimodalData objects . If focus_list is None focus_list = [ self . _selected ] Parameters
def filter_data(self,
        select_singlets: Optional[bool] = False,
        remap_string: Optional[str] = None,
        subset_string: Optional[str] = None,
        min_genes: Optional[int] = None,
        max_genes: Optional[int] = None,
        min_umis: Optional[int] = None,
        max_umis: Optional[int] = None,
        mito_prefix: Optional[str] = None,
        percent_mito: Optional[float] = None,
        focus_list: Optional[Union[List[str], str]] = None,
        cache_passqc: Optional[bool] = False,
        uns_white_list: Optional[str] = None,
    ) -> None:
        selected_barcodes = None
        if focus_list is None:
            focus_list = [self._selected]
        elif isinstance(focus_list, str):
            focus_list = [focus_list]
        focus_set = set(focus_list)
        unselected = []
        mito_dict = DictWithDefault(mito_prefix)
        for key, unidata in self.data.items():
            if (key in focus_set) and (unidata.get_modality() == "rna"):
                if ("passed_qc" not in unidata.obs) or (not cache_passqc):
                    calc_qc_filters(unidata,
                        select_singlets = select_singlets,
                        remap_string = remap_string,
                        subset_string = subset_string,
                        min_genes = min_genes,
                        max_genes = max_genes,
                        min_umis = min_umis,
                        max_umis = max_umis,
                        mito_prefix = mito_dict.get(unidata.get_genome()),
                        percent_mito = percent_mito)
                apply_qc_filters(unidata, uns_white_list=uns_white_list)
                selected_barcodes = unidata.obs_names if selected_barcodes is None else selected_barcodes.union(unidata.obs_names)
            else:
                unselected.append(unidata)
        if (selected_barcodes is not None) and len(unselected) > 0:
            for unidata in unselected:
                selected = unidata.obs_names.isin(selected_barcodes)
                prior_n = unidata.shape[0]
                unidata._inplace_subset_obs(selected)
                logger.info(f"After filtration, {unidata.shape[0]} out of {prior_n} cell barcodes are kept in UnimodalData object {unidata.get_uid()}.")
def filter_data ( self , select_singlets : Optional [ bool ] = False , remap_string : Optional [ str ] = None , subset_string : Optional [ str ] = None , min_genes : Optional [ int ] = None , max_genes : Optional [ int ] = None , min_umis : Optional [ int ] = None , max_umis : Optional [ int ] = None , mito_prefix : Optional [ str ] = None , percent_mito : Optional [ float ] = None , focus_list : Optional [ Union [ List [ str ] , str ] ] = None , cache_passqc : Optional [ bool ] = False , uns_white_list : Optional [ str ] = None , ) -> None : selected_barcodes = None if focus_list is None : focus_list = [ self . _selected ] elif isinstance ( focus_list , str ) : focus_list = [ focus_list ] focus_set = set ( focus_list ) unselected = [ ] mito_dict = DictWithDefault ( mito_prefix ) for key , unidata in self . data . items ( ) : if ( key in focus_set ) and ( unidata . get_modality ( ) == "rna" ) : if ( "passed_qc" not in unidata . obs ) or ( not cache_passqc ) : calc_qc_filters ( unidata , select_singlets = select_singlets , remap_string = remap_string , subset_string = subset_string , min_genes = min_genes , max_genes = max_genes , min_umis = min_umis , max_umis = max_umis , mito_prefix = mito_dict . get ( unidata . get_genome ( ) ) , percent_mito = percent_mito ) apply_qc_filters ( unidata , uns_white_list = uns_white_list ) selected_barcodes = unidata . obs_names if selected_barcodes is None else selected_barcodes . union ( unidata . obs_names ) else : unselected . append ( unidata ) if ( selected_barcodes is not None ) and len ( unselected ) > 0 : for unidata in unselected : selected = unidata . obs_names . isin ( selected_barcodes ) prior_n = unidata . shape [ 0 ] unidata . _inplace_subset_obs ( selected ) logger . info ( f"After filtration, {unidata.shape[0]} out of {prior_n} cell barcodes are kept in UnimodalData object {unidata.get_uid()}." )
Filter each "rna" modality UnimodalData in the focus_list separately using the set filtration parameters.
Filter each " rna " modality UnimodalData in the focus_list separately using the set filtration parameters .
"""
        Filter each "rna" modality UnimodalData in the focus_list separately using the set filtration parameters. Then for all other UnimodalData objects, select only barcodes that are in the union of selected barcodes from previously filtered UnimodalData objects.
        If focus_list is None, focus_list = [self._selected]

        Parameters
        ----------
        select_singlets: ``bool``, optional, default ``False``
            If select only singlets.
        remap_string: ``str``, optional, default ``None``
            Remap singlet names using <remap_string>, where <remap_string> takes the format "new_name_i:old_name_1,old_name_2;new_name_ii:old_name_3;...". For example, if we hashed 5 libraries from 3 samples sample1_lib1, sample1_lib2, sample2_lib1, sample2_lib2 and sample3, we can remap them to 3 samples using this string: "sample1:sample1_lib1,sample1_lib2;sample2:sample2_lib1,sample2_lib2". In this way, the new singlet names will be in metadata field with key 'assignment', while the old names will be kept in metadata field with key 'assignment.orig'.
        subset_string: ``str``, optional, default ``None``
            If select singlets, only select singlets in the <subset_string>, which takes the format "name1,name2,...". Note that if --remap-singlets is specified, subsetting happens after remapping. For example, we can only select singlets from sampe 1 and 3 using "sample1,sample3".
        min_genes: ``int``, optional, default: None
            Only keep cells with at least ``min_genes`` genes.
        max_genes: ``int``, optional, default: None
            Only keep cells with less than ``max_genes`` genes.
        min_umis: ``int``, optional, default: None
            Only keep cells with at least ``min_umis`` UMIs.
        max_umis: ``int``, optional, default: None
            Only keep cells with less than ``max_umis`` UMIs.
        mito_prefix: ``str``, optional, default: None
            Prefix for mitochondrial genes. For example, GRCh38:MT-,mm10:mt-.
        percent_mito: ``float``, optional, default: None
            Only keep cells with percent mitochondrial genes less than ``percent_mito`` % of total counts. Only when both mito_prefix and percent_mito set, the mitochondrial filter will be triggered.
        focus_list: ``List[str]`` or ``str``, optional, default None
            Filter each UnimodalData with key in focus_list (and modality is 'rna') separately using the filtration criteria. If only one focus is provided, focus_list can be a string instead of a list.
        cache_passqc: ``bool``, optional, default: ``False``
            If True and "passed_qc" is in a UnimodalData object's obs field, use the cached "passed_qc" instead of recalculating it using 'calc_qc_filters'.
        uns_white_list: ``str``, optional, default: ``None``
            If not None, this is string representing a comma-separated list of uns keywords that should not be removed. In addition, 'genome' and 'modality' will not be removed. All other keys in uns will be removed. If None, do not remove any keyword from uns.
        """
self
select_singlets
Optional[bool]
remap_string
Optional[str]
subset_string
Optional[str]
min_genes
Optional[int]
max_genes
Optional[int]
min_umis
Optional[int]
max_umis
Optional[int]
mito_prefix
Optional[str]
percent_mito
Optional[float]
focus_list
Optional[Union[List[str], str]]
cache_passqc
Optional[bool]
uns_white_list
Optional[str]