hybkit.analysis

Functions for analysis of HybRecord and FoldRecord objects.

Base Analysis

class hybkit.analysis.BaseAnalysis(*args, **kwargs)

Base class for specific analysis class types.

settings = {'allow_mirna_dimers': False, 'count_mode': 'record', 'mirna_sort': True, 'out_delim': ',', 'type_sep': '-'}

Class-level settings. See hybkit.settings.Analysis_settings for descriptions.

Type Analysis

class hybkit.analysis.TypeAnalysis(name=None)

Analysis of segment types included in the analyzed hyb_records.

Before using the analysis, the seg1_type and seg2_type flags must be set for the hyb_record, as is done by hybkit.HybRecord.eval_types(). A count is added to the analysis dict for each hybrid type (Ex: “miRNA-mRNA”) with segments placed in sorted order for non-redundant type-combinations. The analysis additionally reports the number of individual segment types.

Parameters

name (str, optional) – Analysis name

Variables
  • name (str) – Analysis name

  • hybrid_types (Counter) – Counter containing annotated ordered types of seg1 and seg2

  • seg1_types (Counter) – Counter containing annotated type of segment in position seg1

  • seg2_types (Counter) – Counter containing annotated type of segment in position seg2

  • all_seg_types (Counter) – Counter containing position-independent annotated types

add(hyb_record)

Add information from a HybRecord record to analysis.

Parameters

hyb_record (HybRecord) – Record with information to add.

update(add_analysis)

Add another TypeAnalysis object to this one by combining counts.

Parameters

add_analysis (TypeAnalysis) – TypeAnalysis object to add.

results(out_delim=None, newline=False)

Return the results of a type analysis in a list of delimited lines.

Parameters
  • out_delim (str, optional) – Delimiter for entries within lines, such as ‘,’ or ‘\t’. If not provided, defaults to settings['out_delim']

  • newline (bool, optional) – Terminate lines with a newline_character. Default False

Returns

list of string objects representing the results of the analysis.

write(file_name_base, out_delim=None)

Write the results of a type analysis to a file.

Parameters
  • file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

  • out_delim (str, optional) – Delimiter to write between fields. Defaults to settings['out_delim'] if not provided.

plot(file_name_base)

Create plots of the results using hybkit.plot.type_count().

Parameters

file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

settings = {'allow_mirna_dimers': False, 'count_mode': 'record', 'mirna_sort': True, 'out_delim': ',', 'type_sep': '-'}

Class-level settings. See hybkit.settings.Analysis_settings for descriptions.

miRNA Analysis

class hybkit.analysis.MirnaAnalysis(name=None)

Analyze counts/types of miRNA in hyb records.

The mirna_count analysis determines what type each record is with regard to mirna and counts them accordingly. This includes:

mirnas_5p: Hybrids with a 5p miRNA.
mirnas_3p: Hybrids with a 3p miRNA.
mirna_dimers: Hybrids with both a 5p and 3p miRNA.
non_mirnas: Hybrids with no miRNA.
has_mirna: Hybrids with a miRNA (one of first three categories).

Before using the analysis, the mirna_seg flag must be set for each record as can be done by sequential use of the hybkit.HybRecord.eval_types() and hybkit.HybRecord.eval_mirna() methods.

Parameters

name (str, optional) – Analysis name

Variables
  • name (str) – Analysis name

  • mirnas_5p (int) – Count of 5p miRNAs detected

  • mirnas_3p (int) – Count of 3p miRNAs detected

  • mirna_dimers (int) – Count of miRNA dimers (5p + 3p) detected

  • non_mirnas (int) – Count of non-miRNA hybrids detected

  • has_mirna (int) – Hybrids with 5p, 3p, or both as miRNA

add(hyb_record)

Add information from a HybRecord record to analysis.

Parameters

hyb_record (HybRecord) – Record with information to add.

update(add_analysis)

Add another MirnaAnalysis object to this one by combining counts.

Parameters

add_analysis (MirnaAnalysis) – MirnaAnalysis object to add.

results(out_delim=None, newline=False)

Return the results of a miRNA analysis in a list of delimited lines.

Parameters
  • out_delim (str, optional) – Delimiter for entries within lines, such as ‘,’ or ‘\t’. If not provided, defaults to settings['out_delim']

  • newline (bool, optional) – Terminate lines with a newline_character. Default False

Returns

list of string objects representing the results of the analysis.

write(file_name_base, out_delim=None)

Write the results of a type analysis to a file.

Parameters
  • file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

  • out_delim (str, optional) – Delimiter to write between fields. Defaults to settings['out_delim'] if not provided.

plot(file_name_base)

Create plots of the results using hybkit.plot.mirna().

Parameters

file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

settings = {'allow_mirna_dimers': False, 'count_mode': 'record', 'mirna_sort': True, 'out_delim': ',', 'type_sep': '-'}

Class-level settings. See hybkit.settings.Analysis_settings for descriptions.

Summary Analysis

class hybkit.analysis.SummaryAnalysis(name=None)

Analysis of segment types and miRNA counts in hyb records.

This analysis includes the components of both the TypeAnalysis and MirnaAnalysis analyses, performed simultaneously.

Parameters

name (str, optional) – Analysis name

Variables
  • name (str) – Analysis name

  • hybrid_types (Counter) – Counter containing annotated ordered types of seg1 and seg2

  • seg1_types (Counter) – Counter containing annotated type of segment in position seg1

  • seg2_types (Counter) – Counter containing annotated type of segment in position seg2

  • all_seg_types (Counter) – Counter containing position-independent annotated types

  • mirnas_5p (int) – Count of 5p miRNAs detected

  • mirnas_3p (int) – Count of 3p miRNAs detected

  • mirna_dimers (int) – Count of miRNA dimers (5p + 3p) detected

  • non_mirnas (int) – Count of non-miRNA hybrids detected

  • has_mirna (int) – Hybrids with 5p, 3p, or both as miRNA

add(hyb_record)

Add information from a hybkit.HybRecord record to analysis.

Parameters

hyb_record (HybRecord) – Record with information to add.

update(add_analysis)

Add another SummaryAnalysis object to this one by combining counts.

Parameters

add_analysis (SummaryAnalysis) – SummaryAnalysis object to add.

results(out_delim=None, newline=False)

Return the results of a miRNA analysis in a list of delimited lines.

Parameters
  • out_delim (str, optional) – Delimiter for entries within lines, such as ‘,’ or ‘\t’. If not provided, defaults to settings['out_delim']

  • newline (bool, optional) – Terminate lines with a newline_character. Default False

Returns

list of string objects representing the results of the analysis.

write(file_name_base, out_delim=None)

Write the results of a type analysis to a file.

Parameters
  • file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

  • out_delim (str, optional) – Delimiter to write between fields. Defaults to settings['out_delim'] if not provided.

plot(file_name_base)

Create plots of results via hybkit.plot.type_count() and hybkit.plot.mirna().

Parameters

file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

settings = {'allow_mirna_dimers': False, 'count_mode': 'record', 'mirna_sort': True, 'out_delim': ',', 'type_sep': '-'}

Class-level settings. See hybkit.settings.Analysis_settings for descriptions.

Target Analysis

class hybkit.analysis.TargetAnalysis(name=None)

Class for analysis of targets in miRNA-containing hybrids.

The mirna_target analysis provides an analysis of what sequences are targeted by each respective miRNA within the hyb records. The analysis dict has keys of each miRNA, with each value being a dict of targeted sequences and their associated count of times targeted.

Before using the analysis, the seg1_type, seg2_type, and mirna_seg flags must be set for each record as can be done by sequential use of the hybkit.HybRecord.eval_types() and hybkit.HybRecord.eval_mirna() methods.

Parameters

name (str, optional) – Analysis name

Variables
  • name (str) – Analysis name

  • targets_5p (int) – Count of 5p miRNAs detected

  • targets_3p (int) – Count of 3p miRNAs detected

  • target_dimers (int) – Count of miRNA dimers (5p + 3p) detected

  • non_targets (int) – Count of non-miRNA hybrids detected

  • has_target (int) – Hybrids with 5p, 3p, or both, as miRNA

add(hyb_record)

Add the information from a HybRecord to a mirna_target analysis.

Parameters

hyb_record (HybRecord) – Record with information to add.

update(add_analysis)

Add another TargetAnalysis object to this one by combining counts.

Parameters

add_analysis (TargetAnalysis) – TargetAnalysis object to add.

process_target_analysis()

Summarize results of the target analysis.

This fills the analysis variables:

mirna_target_total_counts : Counter with keys of miRNA names and values of miRNA total counts.
mirna_target_type_counts : Dict with keys of miRNA names and values of Counter objects, with each counter object containin the count of segment types targeted by that miRNA.
results(out_delim=None, newline=False)

Return the results of a miRNA analysis in a list of delimited lines.

Parameters
  • out_delim (str, optional) – Delimiter for entries within lines, such as ‘,’ or ‘\t’. If not provided, defaults to settings['out_delim']

  • newline (bool, optional) – Terminate lines with a newline_character. Default False

Returns

list of string objects representing the results of the analysis.

write(file_name_base, out_delim=None)

Write the results of the target analysis to a file.

Parameters
  • file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

  • out_delim (str, optional) – Delimiter to write between fields. Defaults to settings['out_delim'] if not provided.

write_individual(file_name_base, out_delim=None)

Write the results of the target analysis to individual files per miRNA.

Parameters
  • file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

  • out_delim (str, optional) – Delimiter to write between fields. Defaults to settings['out_delim'] if not provided.

plot(file_name_base)

Plot targets of all miRNAs in analysis.

Parameters

file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

plot_individual(file_name_base)

Plot targets of each individual miRNA in analysis.

Parameters

file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

settings = {'allow_mirna_dimers': False, 'count_mode': 'record', 'mirna_sort': True, 'out_delim': ',', 'type_sep': '-'}

Class-level settings. See hybkit.settings.Analysis_settings for descriptions.

Fold Analysis

class hybkit.analysis.FoldAnalysis(name=None)

Evaluate and quantify predicted miRNA binding patterns.

This analysis evaluates the predicted binding of miRNA within hyb records that contain a miRNA and have an associated FoldRecord object as the attribute fold_record. This includes an analysis and plotting of the predicted binding by position among the provided miRNA.

Before using the analysis, the mirna_seg flag must be set for each record as can be done by sequential use of the hybkit.HybRecord.eval_types() and hybkit.HybRecord.eval_mirna() methods.

The analysis dict contains the keys:
mirna_folds: Number of miRNA folds represented.
mirna_fold_counts: A by-index count of whether a miRNA is predicted to be base-paired
mirna_fold_frac: A by-index count of the percent of miRNAs paird at each index
Parameters

name (str, optional) – Analysis name

Variables
  • name (str) – Analysis name

  • mirna_folds (int) – Number of miRNA folds represented

  • mirna_fold_counts (dict) – Dict with keys of miRNA index and values of number of miRNAs folded at that index

  • mirna_fold_frac (dict) – Dict with keys of miRNA index and values of percent of miRNAs folded at that index

add(hyb_record)

Add the information from a HybRecord to a mirna_fold analysis.

If the record contains a single miRNA, the miRNA fold is identified. miRNA Dimers are skipped unless the settings['all_mirna_dimers'] setting is True. The count for this miRNA and its target is then added to mirna_fold_counts and mirna_fold_frac is recalculated.

Parameters

hyb_record (HybRecord) – Record with information to add.

update(add_analysis)

Add another FoldAnalysis object to this one by combining counts.

Parameters

add_analysis (FoldAnalysis) – FoldAnalysis object to add.

results(out_delim=None, newline=False)

Return the results of a miRNA analysis in a list of delimited lines.

Parameters
  • out_delim (str, optional) – Delimiter for entries within lines, such as ‘,’ or ‘\t’. If not provided, defaults to settings['out_delim']

  • newline (bool, optional) – Terminate lines with a newline_character. Default False

Returns

list of string objects representing the results of the analysis.

write(file_name_base, out_delim=None)

Write the results of the fold analysis to files.

Parameters
  • file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

  • out_delim (str, optional) – Delimiter to write between fields. Defaults to settings['out_delim'] if not provided.

plot(file_name_base)

Create plots of the results.

Parameters

file_name_base (str) – “Base” name for output files. Final file names will be generated based on analysis type and provided parameters.

settings = {'allow_mirna_dimers': False, 'count_mode': 'record', 'mirna_sort': True, 'out_delim': ',', 'type_sep': '-'}

Class-level settings. See hybkit.settings.Analysis_settings for descriptions.