pegasusio/qc_utils.py
def apply_qc_filters(unidata: UnimodalData, uns_white_list: str = None):
    """ Apply QC filters to filter out low quality cells """
    if "passed_qc" in unidata.obs:
        prior_n = unidata.shape[0]
        unidata._inplace_subset_obs(unidata.obs["passed_qc"])

        cols = ["passed_qc"]
        if unidata.uns.get("__del_demux_type", False):
            cols.append("demux_type")
            if "assignment" in unidata.obs:
                # remove categories that contain no elements
                series = unidata.obs["assignment"].value_counts(sort = False)
                unidata.obs["assignment"] = pd.Categorical(unidata.obs["assignment"], categories = series[series > 0].index.astype(str))
            # del unidata.uns["__del_demux_type"]

        unidata.obs.drop(columns=cols, inplace=True)
        if len(unidata.obsm) > 0:
            unidata.obsm.clear()
        if len(unidata.varm) > 0:
            unidata.varm.clear()
        if uns_white_list is not None:
            white_list = set(uns_white_list.split(',') + ['genome', 'modality'])
            for key in list(unidata.uns):
                if key not in white_list:
                    del unidata.uns[key]
        logger.info(f"After filtration, {unidata.shape[0]} out of {prior_n} cell barcodes are kept in UnimodalData object {unidata.get_uid()}.")
 Apply QC filters to filter out low quality cells 
Apply QC filters to filter out low quality cells
Apply QC filters to filter out low quality cells
def apply_qc_filters(unidata: UnimodalData, uns_white_list: str = None):
    if "passed_qc" in unidata.obs:
        prior_n = unidata.shape[0]
        unidata._inplace_subset_obs(unidata.obs["passed_qc"])
        cols = ["passed_qc"]
        if unidata.uns.get("__del_demux_type", False):
            cols.append("demux_type")
            if "assignment" in unidata.obs:
                series = unidata.obs["assignment"].value_counts(sort = False)
                unidata.obs["assignment"] = pd.Categorical(unidata.obs["assignment"], categories = series[series > 0].index.astype(str))
        unidata.obs.drop(columns=cols, inplace=True)
        if len(unidata.obsm) > 0:
            unidata.obsm.clear()
        if len(unidata.varm) > 0:
            unidata.varm.clear()
        if uns_white_list is not None:
            white_list = set(uns_white_list.split(',') + ['genome', 'modality'])
            for key in list(unidata.uns):
                if key not in white_list:
                    del unidata.uns[key]
        logger.info(f"After filtration, {unidata.shape[0]} out of {prior_n} cell barcodes are kept in UnimodalData object {unidata.get_uid()}.")
def apply_qc_filters ( unidata : UnimodalData , uns_white_list : str = None ) : if "passed_qc" in unidata . obs : prior_n = unidata . shape [ 0 ] unidata . _inplace_subset_obs ( unidata . obs [ "passed_qc" ] ) cols = [ "passed_qc" ] if unidata . uns . get ( "__del_demux_type" , False ) : cols . append ( "demux_type" ) if "assignment" in unidata . obs : series = unidata . obs [ "assignment" ] . value_counts ( sort = False ) unidata . obs [ "assignment" ] = pd . Categorical ( unidata . obs [ "assignment" ] , categories = series [ series > 0 ] . index . astype ( str ) ) unidata . obs . drop ( columns = cols , inplace = True ) if len ( unidata . obsm ) > 0 : unidata . obsm . clear ( ) if len ( unidata . varm ) > 0 : unidata . varm . clear ( ) if uns_white_list is not None : white_list = set ( uns_white_list . split ( ',' ) + [ 'genome' , 'modality' ] ) for key in list ( unidata . uns ) : if key not in white_list : del unidata . uns [ key ] logger . info ( f"After filtration, {unidata.shape[0]} out of {prior_n} cell barcodes are kept in UnimodalData object {unidata.get_uid()}." )
Apply QC filters to filter out low quality cells
Apply QC filters to filter out low quality cells
""" Apply QC filters to filter out low quality cells """ # remove categories that contain no elements # del unidata.uns["__del_demux_type"]
unidata
UnimodalData
uns_white_list
str