rnalysis.filtering.FoldChangeFilter.filter_by_gtf_attribute
- FoldChangeFilter.filter_by_gtf_attribute(gtf_path: str | Path, attribute: Literal['gene_biotype', 'transcript_biotype', 'biotype', 'gene_name', 'gene_id', 'transcript_id', 'chromosome', 'source', 'strand'] | str = 'gene_biotype', value: str | List[str] = 'protein_coding', feature_type: Literal['gene', 'transcript'] = 'gene', opposite: bool = False, inplace: bool = True)
Filters the features in the table by any attribute described in a GTF/GFF annotation file, keeping only features whose attribute matches one of the specified values (for example: keep only genes on a specific chromosome or strand, from a specific source, or of a specific biotype). This is a generalization of filter_biotype_from_gtf to any GTF/GFF attribute.
- Parameters:
gtf_path (str or Path) – Path to your GTF/GFF annotation file. The file should match the type of gene names/IDs you use in your table.
attribute (str (default='gene_biotype')) – name of the attribute to filter by. Standard column-9 attributes (such as ‘gene_biotype’, ‘gene_name’, or any custom key in your file) are supported, as well as the reserved names ‘chromosome’, ‘source’ and ‘strand’, which are read from the fixed columns of the annotation file.
value (str or list of strings) – the attribute value/values which will NOT be filtered out. For example, to keep only the features on chromosomes ‘chr1’ and ‘chr2’, set attribute=’chromosome’ and value=[‘chr1’, ‘chr2’].
feature_type ('gene' or 'transcript' (default='gene')) – determines whether the features/rows in your data table describe individual genes or transcripts.
opposite (bool) – If True, the output of the filtering will be the OPPOSITE of the specified (instead of filtering out X, the function will filter out anything BUT X). If False (default), the function will filter as expected.
inplace (bool (default=True)) – If True (default), filtering will be applied to the current Filter object. If False, the function will return a new Filter instance and the current instance will not be affected.
- Returns:
If ‘inplace’ is False, returns a new and filtered instance of the Filter object.