rnalysis.filtering.CountFilter
- class rnalysis.filtering.CountFilter(fname: str | Path | tuple, drop_columns: str | List[str] = None, is_normalized: bool = False, suppress_warnings: bool = False)
A class that receives a count matrix and can filter it according to various characteristics.
Attributes
- df: pandas DataFrame
A DataFrame that contains the count matrix contents. The DataFrame is modified upon usage of filter operations.
- shape: tuple (rows, columns)
The dimensions of df.
- columns: list
The columns of df.
- fname: pathlib.Path
The path and filename for the purpose of saving df as a csv file. Updates automatically when filter operations are applied.
- index_set: set
All of the indices in the current DataFrame (which were not removed by previously used filter methods) as a set.
- index_string: string
A string of all feature indices in the current DataFrame separated by newline.
- triplicates: list
Returns a nested list of the column names in the CountFilter, grouped by alphabetical order into triplicates. For example, if counts.columns is [‘A_rep1’,’A_rep2’,’A_rep3’,’B_rep1’,’B_rep2’,_B_rep3’], then counts.triplicates will be [[‘A_rep1’,’A_rep2’,’A_rep3’],[‘B_rep1’,’B_rep2’,_B_rep3’]]
- __init__(fname: str | Path | tuple, drop_columns: str | List[str] = None, is_normalized: bool = False, suppress_warnings: bool = False)
Load a count matrix. A valid count matrix should have one row per gene/genomic feature and one column per condition/RNA library. The contents of the count matrix can be raw or pre-normalized.
- Parameters:
fname (Union[str, Path]) – full path/filename of the .csv file to be loaded into the Filter object
drop_columns (str, list of str, or None (default=None)) – if a string or list of strings are specified, the columns of the same name/s will be dropped from the loaded table.
is_normalized (bool (default=False)) – indicates whether this count table is pre-normalized. RNAlysis issues a warning when a function meant for normalized tables is applied to a table that was not already normalized.
|
Average the expression values of gene expression for each group of replicate samples. |
|
Returns a DataFrame describing the biotypes in the table and their count. |
Returns a DataFrame describing the biotypes in the table and their count. |
|
|
Generates a box plot of the specified samples in the CountFilter object in log10 scale. |
|
Performs hierarchical clustering and plots a clustergram on the base-2 log of a given set of samples. |
|
|
|
Generate descriptive statistics that summarize the central tendency, dispersion and shape of the dataset's distribution, excluding NaN values. |
|
Keep only the features that exist in the first Filter object/set but NOT in the others. |
Run differential expression analysis on the count matrix using the DESeq2 algorithm. |
|
Run differential expression analysis on the count matrix using the DESeq2 algorithm. |
|
Run differential expression analysis on the count matrix using the Limma-Voom pipeline. The count matrix you are analyzing should be normalized (typically to Reads Per Million). The analysis will be based on a design matrix supplied by the user. The design matrix should contain at least two columns: the first column contains all the sample names, and each of the following columns contains an experimental design factor (e.g. 'condition', 'replicate', etc). (see the User Guide and Tutorial for a complete example). The analysis formula will contain all the factors in the design matrix. To run this function, a version of R must be installed. |
|
|
Run differential expression analysis on the count matrix using the Limma-Voom pipeline. The simplified mode supports only pairwise comparisons. The count matrix you are analyzing should be normalized (typically to Reads Per Million). The analysis will be based on a design matrix supplied by the user. The design matrix should contain at least two columns: the first column contains all the sample names, and each of the following columns contains an experimental design factor (e.g. 'condition', 'replicate', etc). (see the User Guide and Tutorial for a complete example). The analysis formula will contain all the factors in the design matrix. To run this function, a version of R must be installed. |
|
Drop specific columns from the table. |
|
Generates an enhanced box-plot of the specified samples in the CountFilter object in log10 scale. |
|
Filters out all features that do not match the indicated biotype/biotypes (for example: 'protein_coding', 'ncRNA', etc). |
Filters out all features that do not match the indicated biotype/biotypes (for example: 'protein_coding', 'ncRNA', etc). |
|
Filters features according to user-defined attributes from an Attribute Reference Table. |
|
Filters genes according to GO annotations, keeping only genes that are annotated with a specific GO term. |
|
|
Filters genes according to KEGG pathways, keeping only genes that belong to specific KEGG pathway. |
|
Filter out specific rows from the table by their name (index). |
|
Removes features/rows whose sum is belove 'threshold'. |
|
Filter out rows with duplicate names/IDs (index). |
|
Filter out features which are lowly-expressed in all columns, keeping only features with at least 'threshold' reads in at least 'n_samples' columns. |
|
Remove all rows whose values in the specified columns are missing (NaN). |
|
Removes all entries above the specified percentile in the specified column. |
|
Sort the rows by the values of specified column or columns, then keep only the top 'n' rows. |
Find paralogs within the same species using the Ensembl database. |
|
Find paralogs within the same species using the PantherDB database. |
|
|
Calculate the fold change between the numerator condition and the denominator condition, and return it as a FoldChangeFilter object. |
|
|
|
Iterates over count .txt files in a given folder and combines them into a single CountFilter table. |
|
Iterates over HTSeq count .txt files in a given folder and combines them into a single CountFilter table. |
|
Return the first n rows of the Filter object. |
|
|
|
Keep only the features that exist in ALL of the given Filter objects/sets. |
|
Generates M-A (log-ratio vs. |
Returns a set/string of the features that appear in at least (majority_threhold * 100)% of the given Filter objects/sets. |
|
|
Map genes to their nearest orthologs in a different species using the Ensembl database. |
Map genes to their nearest orthologs in a different species using the OrthoInspector database. |
|
|
Map genes to their nearest orthologs in a different species using the PantherDB database. |
|
Map genes to their nearest orthologs in a different species using the PhylomeDB database. This function generates a table describing all matching discovered ortholog pairs (both unique and non-unique) and returns it, and can also translate the genes in this data table into their nearest ortholog, as well as remove unmapped genes. |
Normalizes the count matrix using the 'Median of Ratios Normalization' (MRN) method (Maza et al 2013). |
|
|
Normalizes the count matrix using the 'Relative Log Expression' (RLE) method (Anders and Huber 2010). |
|
Normalizes the count matrix using the 'trimmed mean of M values' (TMM) method (Robinson and Oshlack 2010). |
Normalizes the count matrix using the quantile method, generalized from Bullard et al 2010. |
|
|
Normalizes the count matrix to Reads Per Kilobase Million (RPKM). Divides each column in the count matrix by (total reads)*(gene length / 1000)*10^-6. |
|
Normalizes the count matrix to Reads Per Million (RPM). |
Normalizes the count matrix to Reads Per Million (RPM). |
|
|
Normalizes the count matrix to Transcripts Per Million (TPM). First, normalizes each gene to Reads Per Kilobase (RPK) by dividing each gene in the count matrix by its length in Kbp (gene length / 1000). Then, divides each column in the RPK matrix by (total RPK in column)*10^-6. This calculation is similar to that of Reads Per Kilobase Million (RPKM), but in the opposite order: the "per million" normalization factors are calculated after normalizing to gene lengths, not before. |
Normalizes the reads in the CountFilter using pre-calculated scaling factors. |
|
|
Applay a number filter (greater than, equal, lesser than) on a particular column in the Filter object. |
|
Plot pairwise relationships in the dataset. |
|
Performs Principal Component Analysis (PCA), visualizing the principal components that explain the most variance between the different samples. |
|
Plot the average expression and spread of the specified features under the specified conditions. |
Print the feature indices in the Filter object, sorted by their current order in the FIlter object, and separated by newline. |
|
|
Saves the current filtered data to a .csv file. |
|
Saves the current filtered data to a .parquet file. |
|
Save the current filtered data table. |
|
Generate a scatter plot where every dot is a feature, the x value is log10 of reads (counts, RPM, RPKM, TPM, etc) in sample1, the y value is log10 of reads in sample2. |
|
Sort the rows by the values of specified column or columns. |
Performs Principal Component Analysis (PCA), and sort the table based on the contribution (loadings) of genes to a specific Principal Component. This type of analysis can help you understand which genes contribute the most to each principal component, particularly using single-list enrichment analysis. . |
|
|
Splits the features in the Filter object into multiple Filter objects, each corresponding to one of the specified Attribute Reference Table attributes. |
|
Splits the features in the Filter object into two non-overlapping Filter objects: one containing features below the specified percentile in the specfieid column, and the other containing features about the specified percentile in the specified column. |
Performs Principal Component Analysis (PCA), and split the table based on the contribution (loadings) of genes to specific Principal Components. For each Principal Component specified, RNAlysis will find the X% most influential genes on the Principal Component based on their loadings (where X is gene_fraction), (X/2)% from the top and (X/2)% from the bottom. This type of analysis can help you understand which genes contribute the most to each principal component. |
|
|
Splits the features in the CountFilter object into two non-overlapping CountFilter objects, based on their maximum expression level. |
|
Clusters the features in the CountFilter object using the modified CLICOM ensemble clustering algorithm (Mimaroglu and Yagci 2012), and then splits those features into multiple non-overlapping CountFilter objects, based on the clustering result. |
|
Clusters the features in the CountFilter object using the HDBSCAN clustering algorithm, and then splits those features into multiple non-overlapping CountFilter objects, based on the clustering result. |
|
Clusters the features in the CountFilter object using the Hierarchical clustering algorithm, and then splits those features into multiple non-overlapping CountFilter objects, based on the clustering result. |
|
Clusters the features in the CountFilter object using the K-means clustering algorithm, and then splits those features into multiple non-overlapping CountFilter objects, based on the clustering result. |
|
Clusters the features in the CountFilter object using the K-medoids clustering algorithm, and then splits those features into multiple non-overlapping CountFilter objects, based on the clustering result. |
|
Returns a set/string of the WBGene indices that exist either in the first Filter object/set OR the second, but NOT in both (set symmetric difference). |
|
Return the last n rows of the Filter object. |
|
Applay a text filter (equals, contains, starts with, ends with) on a particular column in the Filter object. |
|
Transform the values in the Filter object with the specified function. |
|
Translates gene names/IDs from one type to another. |
|
Returns a set/string of the union of features between multiple Filter objects/sets (the features that exist in at least one of the Filter objects/sets). |
|
Generates a violin plot of the specified samples in the CountFilter object in log10 scale. |