Sample#
Constructor#
- class itpseq.Sample(replicates=None, *, labels=None, reference=None, dataset=None, keys=('sample',), name=None, **kwargs)[source]
Represents a sample in a dataset, its replicates, reference, and associated metadata.
The Sample class is used to encapsulate information and behavior related to samples in a dataset. It manages details like labels, references, replicates, and metadata, and provides methods for analyzing replicates, performing differential enrichment analysis, and creating visualizations.
Examples
- Get a Sample from a DataSet
>>> sample = dataset['sample_name']
- Compute the differential expression for positions E-P-A.
>>> sample.DE('E:A')
- Attributes:
- itp_len
Combines the counts of inverse-toeprints (ITPs) for each length across all replicates.
This method extracts the counts of inverse-toeprints for each length from the metadata of each replicate and combines them into a single DataFrame, keeping the data for each replicate independent.
- pandas.DataFrame
A DataFrame with the following columns:
- lengthint
The length of the inverse-toeprints.
- replicatestr
The replicate identifier.
- countint
The count of inverse-toeprints of the given length for the replicate.
- samplestr
The name of the sample this data belongs to.
>>> sample.itp_len length replicate count sample 0 51 1 115732.0 spl 1 20 1 444506.0 spl 2 41 1 130495.0 spl 3 23 1 198257.0 spl 4 17 1 55786.0 spl .. ... ... ... ... 328 106 3 NaN spl 329 143 3 NaN spl 330 102 3 NaN spl 331 104 3 NaN spl 332 221 3 NaN spl [333 rows x 4 columns]
name_refName of the Sample combined with its reference
name_vs_refName of the Sample combined with its reference
- toeprint_df
DataFrame of the counts of each inverse toeprint length per Replicate
Methods
DE([pos, how, join, quiet, filter_size, ...])Computes the differential expression between the sample and its reference.
all_logos([logo_kwargs])Creates a logo for all positions for each replicate in the sample.
codon_violin(pos, *[, motif, query, col, ...])Plots violin plots for each amino acid motif, with one line per combination of codons.
copy([name, reference])Creates a copy of the sample.
format_sequences(**kwargs)Display formatted inverse-toeprints for all replicates
get_counts([pos, how])Counts the number of reads for each motif or combination of amino-acid/position for each replicate in the sample.
get_counts_ratio([pos, factor, ...])Outputs the result of get_counts for the sample and its reference and add extra columns: the normalized averages and the sample/reference ratio.
get_counts_ratio_pos([pos, how])Computes a DataFrame with the enrichment ratios for each ribosome position.
hmap([r, c, pos, col, transform, cmap, ...])Generates a heatmap of enrichment for combinations of 2 positions.
hmap_grid([pos, col, transform, cmap, vmax, ...])Creates a grid of heatmaps for all combinations of ribosome positions passed in pos.
hmap_pos([pos, how, transform, cmap, vmax, ...])Generates a heatmap of enrichment ratios per positions across ribosome sites.
infos([html])Returns a table with information on the NGS reads per replicate.
itoeprint([plot, norm, norm_range, ...])Plots a virtual inverse-toeprint gel.
itp_len_plot([ax, min_codon, max_codon, ...])Generates a plot of inverse-toeprint (ITP) counts per length.
load_replicates([how])Loads all the Replicates in the Sample with the defined method (
how)logo([pos, logo_kwargs, ax, vs_ref, how])Creates a logo for the selected positions.
rename(name[, rename_replicates])Changes the name of the sample.
subset_logo(pos, *[, how, query, motif, ...])Creates a logo from a subset of the Differential Expression data.
volcano([pos, query, motif, ax, x, y, ...])Draws a volcano plot from the Differential Expression data.
Methods#
|
Changes the name of the sample. |
|
Creates a copy of the sample. |
|
Returns a table with information on the NGS reads per replicate. |
|
Counts the number of reads for each motif or combination of amino-acid/position for each replicate in the sample. |
|
Outputs the result of get_counts for the sample and its reference and add extra columns: the normalized averages and the sample/reference ratio. |
|
Computes a DataFrame with the enrichment ratios for each ribosome position. |
|
Computes the differential expression between the sample and its reference. |
|
Plots violin plots for each amino acid motif, with one line per combination of codons. |
|
Generates a heatmap of enrichment for combinations of 2 positions. |
|
Creates a grid of heatmaps for all combinations of ribosome positions passed in pos. |
|
Generates a heatmap of enrichment ratios per positions across ribosome sites. |
|
Draws a volcano plot from the Differential Expression data. |
|
Creates a logo from a subset of the Differential Expression data. |
|
Creates a logo for the selected positions. |
|
Creates a logo for all positions for each replicate in the sample. |
|
Generates a plot of inverse-toeprint (ITP) counts per length. |
|
Plots a virtual inverse-toeprint gel. |