[Genabel-commits] r1691 - pkg/ProbABEL/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Apr 22 12:18:40 CEST 2014
Author: lckarssen
Date: 2014-04-22 12:18:40 +0200 (Tue, 22 Apr 2014)
New Revision: 1691
Modified:
pkg/ProbABEL/src/regdata.cpp
pkg/ProbABEL/src/regdata.h
Log:
Added Doxygen documentation to ProbABEL's regdata class and its functions.
Modified: pkg/ProbABEL/src/regdata.cpp
===================================================================
--- pkg/ProbABEL/src/regdata.cpp 2014-04-15 20:38:49 UTC (rev 1690)
+++ pkg/ProbABEL/src/regdata.cpp 2014-04-22 10:18:40 UTC (rev 1691)
@@ -1,6 +1,13 @@
-/*
- * regdata.cpp
+/**
+ * \file regdata.cpp
+ * \author Yurii S. Aulchenko
+ * \author M. Kooyman
+ * \author L.C. Karssen
+ * \author Maksim V. Struchalin
*
+ * \brief Describes functions of the regdata class containing a
+ * linear or logistic regression object.
+ *
* Created on: Mar 29, 2012
* Author: mkooyman
*
@@ -39,6 +46,11 @@
#include <algorithm> // STL algoritms
#include "regdata.h"
+
+/**
+ * Constructor. Initialises all values to zero.
+ *
+ */
regdata::regdata()
{
nids = 0;
@@ -52,6 +64,13 @@
}
+/**
+ * Copy constructor. Creates a regdata object by copying the values of
+ * another one.
+ *
+ * \param obj Reference to the regdata object to be copied to the new
+ * object
+ */
regdata::regdata(const regdata &obj) : X(obj.X), Y(obj.Y)
{
nids = obj.nids;
@@ -67,6 +86,19 @@
}
+/**
+ * Constructor that fills a regdata object with phenotype and genotype
+ * data.
+ *
+ * \param phed Reference to a phedata object with phenotype data
+ * \param gend Reference to a gendata object with genotype data
+ * \param snpnum The number of the SNP in the genotype data object to
+ * be added to the design matrix regdata::X. When set to a number < 0
+ * no SNP data is added to the design matrix (e.g. when calculating
+ * the null model).
+ * \param ext_is_interaction_excluded Boolean that shows whether
+ * interactions are excluded.
+ */
regdata::regdata(phedata &phed, gendata &gend, const int snpnum,
const bool ext_is_interaction_excluded)
{
@@ -123,6 +155,18 @@
}
+/**
+ * Update the SNP dosages/probabilities in the design matrix
+ * regdata::X.
+ *
+ * Adds the genetic information for a new SNP to the design
+ * matrix.
+ *
+ * @param gend Object that contains the genetic data from which the
+ * dosages/probabilities will be added to the design matrix.
+ * @param snpnum Number of the SNP for which the dosage/probability
+ * data will be extracted from the gend object.
+ */
void regdata::update_snp(gendata *gend, const int snpnum)
{
// Reset counter for frequency since it is a new SNP
@@ -141,8 +185,8 @@
X.put(snpdata[i], i, (ncov - j));
if (std::isnan(snpdata[i])) {
masked_data[i] = 1;
+ } else {
// SNP not masked
- } else {
// check for first predictor
if (j == 0) {
gcount++;
@@ -155,11 +199,11 @@
// Add second genotype in two predicor data form
freq += snpdata[i] * 0.5;
}
- } // End std::isnan(snpdata[i]) snp
- } // End i for loop
+ } // End if std::isnan(snpdata[i]) snp
+ } // End for loop: i = 0 to nids
delete[] snpdata;
- } // End ngpreds loop
+ } // End for loop: j = 0 to ngpreds
freq /= static_cast<double>(gcount); // Allele frequency
}
@@ -197,6 +241,20 @@
//}
+/**
+ * Create a new regdata object that contains only the non-masked
+ * data.
+ *
+ * The non-masked data is extracted according to the data in the
+ * regdata::masked_data array. The resulting regdata::nids corresponds
+ * to the number of IDs for which genotype data is present.
+ *
+ * Note that the regdata::masked_data array of the new object should
+ * contain only zeros (i.e. not masked).
+ *
+ * @return A new regdata object containing only the rows from
+ * regdata::X and regdata::Y for which genotype data is present.
+ */
regdata regdata::get_unmasked_data()
{
regdata to; // = regdata(*this);
@@ -238,6 +296,13 @@
}
+/**
+ * Extracts the genotype data from the design matrix regdata::X of a
+ * regdata object.
+ *
+ * @return A new mematrix object of dimensions regdata::X.nrow x
+ * ngpreds that contains the genotype data.
+ */
mematrix<double> regdata::extract_genotypes(void)
{
mematrix<double> out;
Modified: pkg/ProbABEL/src/regdata.h
===================================================================
--- pkg/ProbABEL/src/regdata.h 2014-04-15 20:38:49 UTC (rev 1690)
+++ pkg/ProbABEL/src/regdata.h 2014-04-22 10:18:40 UTC (rev 1691)
@@ -1,6 +1,13 @@
-/*
- * regdata.h
+/**
+ * \file regdata.h
+ * \author Yurii S. Aulchenko
+ * \author M. Kooyman
+ * \author L.C. Karssen
+ * \author Maksim V. Struchalin
*
+ * \brief Describes the regdata class containing a linear or logistic
+ * regression object.
+ *
* Created on: Mar 29, 2012
* Author: mkooyman
*
@@ -39,27 +46,99 @@
#include "gendata.h"
#include "phedata.h"
+
+/**
+ * \brief A regdata object contains data used for linear or
+ * logistic regression.
+ *
+ * A similar object for CoxPH regression can be found in the
+ * coxph_data class.
+ *
+ */
class regdata {
public:
- int nids;
+ int nids; /**< Number of IDs/samples. */
+
+ /**
+ * Number of covariates + possible nr of genomic predictors.
+ *
+ * If snpnum >=0 then this equals the number of covariates + the
+ * number of regdata::ngpreds.
+ */
int ncov;
+
+ /**
+ * Number of genomic predictors, 1 for dosage data, 2 for
+ * probability data.
+ *
+ */
int ngpreds;
+
+ /**
+ * Number of outcomes, taken from phedata::noutcomes.
+ */
int noutcomes;
+
+ /**
+ * Boolean that indicates whether the command line option
+ * --interaction_only was set.
+ *
+ * See cmdvars::is_interaction_excluded.
+ */
bool is_interaction_excluded;
+
+ /**
+ * Pointer to an array that contains ones/zeros to indicate which
+ * data points should be omitted because no genetic data is
+ * present.
+ *
+ * The array is regdata::nids long. A value of 1 means that that
+ * ID/sample will be masked because the SNP data is NA for that
+ * ID.
+ */
unsigned short int * masked_data;
+
+ /**
+ * Number of non-masked genotypes.
+ */
unsigned int gcount;
+
+ /**
+ * Allele frequency.
+ *
+ * Calculation is only based on non-masked SNPs.
+ */
double freq;
+
+ /**
+ * The design matrix.
+ *
+ * The matrix dimensions are regdata::nids x (regdata::ncov + 1)
+ */
mematrix<double> X;
+
+ /**
+ * Matrix containing the phenotype data.
+ *
+ * The matrix dimensions are regdata::nids x
+ * regdata::noutcomes.
+ */
mematrix<double> Y;
+
+
+ // Constructors and destructors
regdata();
regdata(const regdata &obj);
regdata(phedata &phed, gendata &gend, const int snpnum,
const bool ext_is_interaction_excluded);
- mematrix<double> extract_genotypes();
+ //~regdata();
+
+
+ // Member functions.
void update_snp(gendata *gend, const int snpnum);
void remove_snp_from_X();
regdata get_unmasked_data();
- //~regdata();
+ mematrix<double> extract_genotypes();
private:
};
More information about the Genabel-commits
mailing list