topicks
Pick top genes for downstream analyses
Loading...
Searching...
No Matches
topicks::TopQueue< Stat_, Index_ > Class Template Reference

Priority queue for retaining top genes. More...

#include <TopQueue.hpp>

Public Member Functions

 TopQueue (const Index_ top, const bool larger, const TopQueueOptions< Stat_ > &options)
 
void push (std::pair< Stat_, Index_ > gene)
 
void emplace (Stat_ statistic, Index_ index)
 
Index_ size () const
 
bool empty () const
 
const std::pair< Stat_, Index_ > & top () const
 
void pop ()
 

Detailed Description

template<typename Stat_, typename Index_>
class topicks::TopQueue< Stat_, Index_ >

Priority queue for retaining top genes.

Template Parameters
Stat_Numeric type of the statistic for ranking top genes.
Index_Integer type of gene index.

The TopQueue class retains the indices of the top genes, analogous to pick_top_genes_index(). This is useful if the user does not want to store an array of statistics for all genes; instead, the statistics can be computed for each gene and added to this queue to reduce memory usage.

Constructor & Destructor Documentation

◆ TopQueue()

template<typename Stat_ , typename Index_ >
topicks::TopQueue< Stat_, Index_ >::TopQueue ( const Index_ top,
const bool larger,
const TopQueueOptions< Stat_ > & options )
inline
Parameters
topNumber of top genes to choose. Note that the actual number of chosen genes may be smaller/larger than top, depending on the number of genes and options.
largerWhether the top genes are defined as those with larger statistics.
optionsFurther options.

Member Function Documentation

◆ push()

template<typename Stat_ , typename Index_ >
void topicks::TopQueue< Stat_, Index_ >::push ( std::pair< Stat_, Index_ > gene)
inline
Parameters
geneThe statistic and the index of a gene. This is inserted into the queue if it is among the top current genes, otherwise no modification is performed.

◆ emplace()

template<typename Stat_ , typename Index_ >
void topicks::TopQueue< Stat_, Index_ >::emplace ( Stat_ statistic,
Index_ index )
inline
Parameters
statisticStatistic for the index-th gene.
indexIndex of the gene.

The gene is inserted into the queue if it is among the top current genes, otherwise no modification is performed.

◆ size()

template<typename Stat_ , typename Index_ >
Index_ topicks::TopQueue< Stat_, Index_ >::size ( ) const
inline
Returns
Size of the queue. This may be more than top if ties are included.

◆ empty()

template<typename Stat_ , typename Index_ >
bool topicks::TopQueue< Stat_, Index_ >::empty ( ) const
inline
Returns
Whether the queue is empty.

◆ top()

template<typename Stat_ , typename Index_ >
const std::pair< Stat_, Index_ > & topicks::TopQueue< Stat_, Index_ >::top ( ) const
inline
Returns
Top item in the queue, i.e., the gene with the smallest (if larger = true) or largest (otherwise) statistic. In case of ties, the gene with the largest index is returned.

This should only be called if empty() returns false.

◆ pop()

template<typename Stat_ , typename Index_ >
void topicks::TopQueue< Stat_, Index_ >::pop ( )
inline

Removes the top item in the queue. This should only be called if empty() returns false.


The documentation for this class was generated from the following file: