Sleipnir
Public Member Functions
Sleipnir::CDataFilter Class Reference

Augments a dataset with a dynamically calculated gene set filter. More...

#include <dataset.h>

Inheritance diagram for Sleipnir::CDataFilter:
Sleipnir::CDataFilterImpl Sleipnir::IDataset

Public Member Functions

void Attach (const IDataset *pDataset, const CGenes &Genes, CDat::EFilter eFilter, const CDat *pAnswers=NULL)
 Associates the data filter with the given dataset, gene set, and filter type.
bool IsExample (size_t iY, size_t iX) const
 Returns true if some data file can be accessed at the requested position.
void Remove (size_t iY, size_t iX)
 Remove all data for the given dataset position.
const std::vector< std::string > & GetGeneNames () const
 Return a vector of all gene names in the dataset.
size_t GetExperiments () const
 Return the number of experimental nodes in the dataset.
size_t GetGene (const std::string &strGene) const
 Return the index of the given gene name, or -1 if it is not included in the dataset.
size_t GetBins (size_t iNode) const
 Return the number of discrete values in the requested experimental node; -1 if the node is hidden or continuous.
size_t GetGenes () const
 Returns the number of genes in the dataset.
bool IsHidden (size_t iNode) const
 Returns true if the requested experimental node is hidden (does not correspond to a data file).
size_t GetDiscrete (size_t iY, size_t iX, size_t iNode) const
 Return the discretized value at the requested position.
float GetContinuous (size_t iY, size_t iX, size_t iNode) const
 Return the continuous value at the requested position.
const std::string & GetGene (size_t iGene) const
 Returns the gene name at the requested index.
void FilterGenes (const CGenes &Genes, CDat::EFilter eFilter)
 Remove values from the dataset based on the given gene set and filter type.
void Save (std::ostream &ostm, bool fBinary) const
 Save a dataset to the given stream in binary or tabular (human readable) form.

Detailed Description

Augments a dataset with a dynamically calculated gene set filter.

A data filter wraps an underlying dataset with a dynamically calculated filter using a gene set and CDat::EFilter type. A filtered gene pair will return false from IsExample and act like missing data. Unfiltered gene pairs will be retrieved from the underlying dataset. This allows data to be temporarily hidden without modifying the underlying dataset.

Remarks:
Remove (and thus FilterGenes) are unimplemented for this class, as their place is essentially taken by its Attach function. Permanent modifications such as these should instead be performed on the underlying dataset.
See also:
CDat::FilterGenes | CDataMask

Definition at line 734 of file dataset.h.


Member Function Documentation

void Sleipnir::CDataFilter::Attach ( const IDataset pDataset,
const CGenes Genes,
CDat::EFilter  eFilter,
const CDat pAnswers = NULL 
)

Associates the data filter with the given dataset, gene set, and filter type.

Parameters:
pDatasetDataset to be associated with the overlaying mask.
GenesGene set used to filter the dataset.
eFilterWay in which to use the given genes to remove gene pairs.
pAnswersIf non-null, answer set to be used for filter types requiring answers (e.g. CDat::EFilterTerm).
Remarks:
No calculation occurs during Attach; the gene set and filter type are stored, and calculations are performed dynamically in IsExample. The gene set is not copied, so the given object should not be destroyed until after the filter. If a filter types requiring an answer file is given without an accompanying answer file, the filter won't crash, but results might be a little odd.

Definition at line 617 of file dataset.cpp.

References Sleipnir::CDat::GetGene(), GetGene(), GetGenes(), and Sleipnir::CGenes::IsGene().

void Sleipnir::CDataFilter::FilterGenes ( const CGenes Genes,
CDat::EFilter  eFilter 
) [inline, virtual]

Remove values from the dataset based on the given gene set and filter type.

Parameters:
GenesGene set used to filter the dataset.
eFilterWay in which to use the given genes to remove values.

Remove values and genes (by removing all incident edges) from the dataset based on one of several algorithms. For details, see CDat::EFilter.

Remarks:
Generally implemented using Remove, so may not be supported by all implementations and may either mask or unload the filtered data.
See also:
CDat::FilterGenes

Implements Sleipnir::IDataset.

Definition at line 782 of file dataset.h.

size_t Sleipnir::CDataFilter::GetBins ( size_t  iNode) const [inline, virtual]

Return the number of discrete values in the requested experimental node; -1 if the node is hidden or continuous.

Parameters:
iNodeExperimental node for which bin number should be returned.
Returns:
Number of discrete values taken by the given experimental node; -1 if the node is hidden or continuous.
See also:
GetDiscrete

Implements Sleipnir::IDataset.

Definition at line 757 of file dataset.h.

float Sleipnir::CDataFilter::GetContinuous ( size_t  iY,
size_t  iX,
size_t  iNode 
) const [inline, virtual]

Return the continuous value at the requested position.

Parameters:
iYData row.
iXData column.
iNodeExperimental node from which to retrieve the requested pair's value.
Returns:
Continuous value from the requested position and data file; not-a-number (NaN) if the value is missing.
Remarks:
Equivalent to using CDataPair::Get on the encapsulated data file with the appropriate indices. Behavior not defined when the corresponding data node is inherently discrete.
See also:
GetDiscrete

Implements Sleipnir::IDataset.

Definition at line 773 of file dataset.h.

References Sleipnir::CMeta::GetNaN(), and IsExample().

size_t Sleipnir::CDataFilter::GetDiscrete ( size_t  iY,
size_t  iX,
size_t  iNode 
) const [inline, virtual]

Return the discretized value at the requested position.

Parameters:
iYData row.
iXData column.
iNodeExperimental node from which to retrieve the requested pair's value.
Returns:
Discretized value from the requested position and data file using that file's quantization information; -1 if the value is missing.
Remarks:
Equivalent to using CDataPair::Quantize and GetContinuous or CDataPair::Get on the encapsulated data file with the appropriate indices. Behavior not defined when no discretization information is available for the requested data node.

Implements Sleipnir::IDataset.

Definition at line 769 of file dataset.h.

References IsExample().

size_t Sleipnir::CDataFilter::GetExperiments ( ) const [inline, virtual]

Return the number of experimental nodes in the dataset.

Returns:
Number of experimental nodes in the dataset.
Remarks:
For most datasets (those not containing hidden nodes), this will be equal to the number of encapsulated data files.

Implements Sleipnir::IDataset.

Definition at line 749 of file dataset.h.

size_t Sleipnir::CDataFilter::GetGene ( const std::string &  strGene) const [inline, virtual]

Return the index of the given gene name, or -1 if it is not included in the dataset.

Parameters:
strGeneGene name to retrieve.
Returns:
Index of the requested gene name, or -1 if it is not in the dataset.
See also:
GetGeneNames

Implements Sleipnir::IDataset.

Definition at line 753 of file dataset.h.

Referenced by Attach(), and GetGene().

const std::string& Sleipnir::CDataFilter::GetGene ( size_t  iGene) const [inline, virtual]

Returns the gene name at the requested index.

Parameters:
iGeneIndex of gene name to return.
Returns:
Gene name at the requested index.
Remarks:
For efficiency, no bounds checking is performed.
See also:
GetGenes

Implements Sleipnir::IDataset.

Definition at line 778 of file dataset.h.

References GetGene().

const std::vector<std::string>& Sleipnir::CDataFilter::GetGeneNames ( ) const [inline, virtual]

Return a vector of all gene names in the dataset.

Returns:
Vector of gene names in the dataset.
See also:
GetGenes | GetGene

Implements Sleipnir::IDataset.

Definition at line 745 of file dataset.h.

size_t Sleipnir::CDataFilter::GetGenes ( ) const [inline, virtual]

Returns the number of genes in the dataset.

Returns:
Number of genes in the dataset.
Remarks:
Equal to the union of all genes in encapsulated data files.
See also:
GetGene

Implements Sleipnir::IDataset.

Definition at line 761 of file dataset.h.

Referenced by Attach().

bool Sleipnir::CDataFilter::IsExample ( size_t  iY,
size_t  iX 
) const [virtual]

Returns true if some data file can be accessed at the requested position.

Parameters:
iYData row.
iXData column.
Returns:
True if a data file can be accessed at the requested position.

A dataset position is a usable example if at least one data file can be accessed at that position; that is, if some data file provides a non-missing value for that gene pair. Implementations that filter pairs in some manner can also prevent particular positions from being usable examples.

Implements Sleipnir::IDataset.

Definition at line 634 of file dataset.cpp.

References Sleipnir::CDat::EFilterEdge, Sleipnir::CDat::EFilterExclude, Sleipnir::CDat::EFilterInclude, Sleipnir::CDat::EFilterTerm, Sleipnir::CDat::Get(), Sleipnir::CGenes::GetGenes(), and Sleipnir::IDataset::IsExample().

Referenced by GetContinuous(), and GetDiscrete().

bool Sleipnir::CDataFilter::IsHidden ( size_t  iNode) const [inline, virtual]

Returns true if the requested experimental node is hidden (does not correspond to a data file).

Parameters:
iNodeExperimental node to investigate.
Returns:
True if the requested experimental node is hidden.

Since a dataset can be constructed either directly on a collection of data files or by tying a model such as a Bayes net to data files, IDataset can determine which model nodes are hidden by testing whether a data file exists for them. If no such file exists, the node is hidden and, for example, can be treated specially during Bayesian learning.

Remarks:
Datasets constructed directly from data files will never have hidden nodes.

Implements Sleipnir::IDataset.

Definition at line 765 of file dataset.h.

void Sleipnir::CDataFilter::Remove ( size_t  iY,
size_t  iX 
) [inline, virtual]

Remove all data for the given dataset position.

Parameters:
iYData row.
iXData column.

Unloads or masks data from all encapsulated files for the requested gene pair.

Remarks:
For efficiency, bounds checking is not performed; the given row and column should both be less than GetGenes. Not supported by all implementations.

Implements Sleipnir::IDataset.

Definition at line 741 of file dataset.h.

void Sleipnir::CDataFilter::Save ( std::ostream &  ostm,
bool  fBinary 
) const [inline, virtual]

Save a dataset to the given stream in binary or tabular (human readable) form.

Parameters:
ostmStream into which dataset is saved.
fBinaryIf true, save the dataset as a binary file; if false, save it as a text-based tab-delimited file.
Remarks:
If fBinary is true, output stream must be binary.

Implements Sleipnir::IDataset.

Definition at line 786 of file dataset.h.


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