Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

matvec::GeneticDist Class Reference

#include <geneticdist.h>

Inheritance diagram for matvec::GeneticDist:

matvec::UnknownDist List of all members.

Detailed Description

a base for Genetic distributions

See also:
StatDist

Definition at line 135 of file geneticdist.h.

Public Methods

 GeneticDist (void)
 GeneticDist (const unsigned nc,...)
 GeneticDist (GeneticDist &G)
virtual ~GeneticDist (void)
const GeneticDist & operator= (const GeneticDist &A)
virtual void resize (const unsigned nc)
virtual unsigned ntrait (void) const
virtual doubleMatrixvar_matrix (void)
const char * name (void) const
ChromStructchrom (void)
double recomb_rate (const unsigned c, const unsigned li, const unsigned lj)
unsigned nchrom (void) const
unsigned nloci_chrom (const unsigned c) const
unsigned nallele (const unsigned c, const unsigned l) const
int display (void)
void copyfrom (const GeneticDist &A)
void nchrom (const unsigned nc)
void nloci (const unsigned nl0,...)
void release (void)
void locus (const unsigned c, const unsigned l, const char qm[], const unsigned na,...)
void putColmNames (const unsigned c, const unsigned l, char nm1[], char nm2[])
void recomb_rate (const unsigned c, const unsigned li, const unsigned lj, const double r)
void genotypic_val (const unsigned c, const unsigned l, const double *v)
void genotypic_val (const unsigned c, const unsigned l, const double v0,...)
double sample (void) const
const double ** genotypic_val (const unsigned c, const unsigned l) const
void multi_loci (int num_loci)
void put_distance (const unsigned c, const unsigned l, double distance)
double get_distance (const unsigned c, const unsigned l)
void locus (const unsigned c, const unsigned l, const char qm[], const unsigned na, Vector< double > allele_freq)

Public Attributes

ChromStructchromosome
unsigned numMarkerLoci
SafeSTLVector< MaternalPaternalRQTLAllelesrqtlVector

Protected Attributes

char distname [25]
unsigned numchrom
unsigned numtrait


Constructor & Destructor Documentation

matvec::GeneticDist::GeneticDist void    [inline]
 

Definition at line 200 of file geneticdist.h.

References chromosome, distname, numchrom, and numtrait.

00201 {
00202    numchrom = 0; chromosome = 0; numtrait = 1;
00203    strcpy(distname,"GeneticDist");
00204 //   cout << "GeneticDist::GeneticDist(void): numtrait = " << numtrait << endl;
00205 }

matvec::GeneticDist::GeneticDist const unsigned    nc,
...   
 

Definition at line 69 of file geneticdist.cpp.

References chromosome, distname, numchrom, numMarkerLoci, numtrait, matvec::ChromStruct::resize(), and resize().

00070 {
00071    numchrom = 0;
00072    chromosome = 0;
00073    numtrait = 1;      // temporary value
00074    numMarkerLoci = 0;
00075    resize(nc);
00076    va_list param_pt;
00077    va_start(param_pt,nc);
00078    unsigned nl;
00079    for (unsigned i=0; i<nc; i++) {
00080       nl = va_arg(param_pt,unsigned);
00081       chromosome[i].resize(nl);
00082    }
00083    va_end(param_pt);
00084    strcpy(distname,"GeneticDist");
00085 }

matvec::GeneticDist::GeneticDist GeneticDist &    G [inline]
 

Definition at line 146 of file geneticdist.h.

References copyfrom().

00146 {copyfrom(G);}

virtual matvec::GeneticDist::~GeneticDist void    [inline, virtual]
 

Definition at line 147 of file geneticdist.h.

References release().

00147 {release();}


Member Function Documentation

ChromStruct* matvec::GeneticDist::chrom void    [inline]
 

Definition at line 158 of file geneticdist.h.

Referenced by matvec::Population::build_pop_gamete(), matvec::Population::build_trans_mat(), matvec::Population::CalcFreqHaploFounders(), matvec::Population::compute_pdm(), matvec::Population::descent_graph_init_parm(), matvec::Population::descent_graph_log_lhood(), matvec::Population::DisplayFreqHaploFounders(), matvec::Individual::getAllelePenetrance(), matvec::Individual::getGenoPenetrance(), matvec::Population::getGNodeListSample(), matvec::Population::getInitialGNodeListSample(), matvec::Population::getOldGNodeListProbability(), matvec::RAlleleFounderSet::getValue(), matvec::GenoFounderSet::getValue(), matvec::AlleleFounderSet::getValue(), matvec::Population::initAlleleNodeList(), matvec::Population::initGenotypeNodeList(), matvec::Population::initJointAlleleNodeList(), matvec::Population::input_data(), matvec::Population::input_markerData(), matvec::Population::LGGenotypeElimination(), matvec::Population::ListAlleleFounders(), matvec::Model::minfun_multipoint(), matvec::Model::multipoint_estimate_Qfreq(), matvec::Population::multipoint_init_parm(), matvec::GNodeList::peelAndCut(), matvec::GNodeList::peelCutAndCompute(), matvec::GNodeList::peelCutAndSample(), matvec::GNodeList::peelOrderCutAndSample(), matvec::Genome::remodel(), matvec::Population::SetFreqHaploFounders(), matvec::Population::SetPossibleHaplotypes(), matvec::Population::setupRSampler(), matvec::Population::SimpleGenotypeElimination(), matvec::Population::sum_genotype_freq1(), matvec::Population::sum_genotype_freq2(), matvec::Population::sum_genotype_freq3(), and matvec::Population::UpdateFreqHaploFounders().

00158 {return chromosome;}

void matvec::GeneticDist::copyfrom const GeneticDist &    A
 

Definition at line 87 of file geneticdist.cpp.

References chromosome, distname, numchrom, numMarkerLoci, numtrait, and resize().

Referenced by GeneticDist(), and operator=().

00088 {
00089    if (this == &A) return;
00090    resize(A.numchrom);
00091    for (unsigned i=0; i<numchrom; i++) chromosome[i] = A.chromosome[i];
00092    strcpy(distname,A.distname);
00093 
00094    numtrait = A.numtrait;  // Occurs in old version
00095    numMarkerLoci = A.numMarkerLoci;  //LRT
00096 }

int matvec::GeneticDist::display void   
 

Definition at line 293 of file geneticdist.cpp.

References chromosome, matvec::ChromStruct::nloci(), and numtrait.

00293                              {
00294   if (chromosome) {
00295     std::cout << "GeneticDist Object: nloci = " << chromosome[0].nloci() << std::endl;
00296              std::cout << "numtrait = " << numtrait <<  std::endl;
00297   }
00298   else {
00299     std::cout << "GeneticDist Object: nloci not initialized yet " << std::endl;
00300     std::cout << "numtrait = " << numtrait <<  std::endl;
00301   }
00302   return 1;
00303 }

const double ** matvec::GeneticDist::genotypic_val const unsigned    c,
const unsigned    l
const [inline]
 

Definition at line 194 of file geneticdist.h.

References chromosome, and matvec::ChromStruct::locus.

00196 {
00197    return (const double**)chromosome[c].locus[l].genotypic_val_mat.begin();
00198 }

void matvec::GeneticDist::genotypic_val const unsigned    c,
const unsigned    l,
const double    v0,
...   
 

Definition at line 187 of file geneticdist.cpp.

References chromosome, matvec::ChromStruct::locus, matvec::ChromStruct::nloci(), and numchrom.

00189 {
00190    if (c < 1 || c>numchrom || l < 1 || l>chromosome[c-1].nloci()) throw exception("GeneticDist::genotypic_val(): bad args");
00191    unsigned i,j,na,cc,ll;
00192    cc = c-1; ll = l-1;
00193    na = chromosome[cc].locus[ll].nallele();
00194    double **me = chromosome[cc].locus[ll].genotypic_val_mat.begin();
00195    me[0][0] = v0;
00196    va_list ppt;
00197    va_start(ppt,v0);
00198    for (j=1; j<na; j++) me[j][0] = me[0][j] = va_arg(ppt,double);
00199    for (i=1;i<na;i++) for (j=i;j<na;j++) me[j][i]=me[i][j]= va_arg(ppt,double);
00200    va_end(ppt);
00201 }

void matvec::GeneticDist::genotypic_val const unsigned    c,
const unsigned    l,
const double *    v
 

Definition at line 169 of file geneticdist.cpp.

References chromosome, and matvec::ChromStruct::locus.

00171 {
00172    ///////////////////////////////////////////
00173    // requiements
00174    // v must have enough elements
00175    ///////////////////////////////////////////
00176    if (c < 1 || c>numchrom || l < 1 || l>chromosome[c-1].nloci()) throw exception("GeneticDist::genotypic_val(): bad args");
00177    unsigned i,j,k,na,cc,ll;
00178    cc = c-1; ll = l-1;
00179    na = chromosome[cc].locus[ll].nallele();
00180    double **me = chromosome[cc].locus[ll].genotypic_val_mat.begin();
00181    for (k=0,i=0; i<na; i++) for (j=0; j<=i; j++) {
00182       me[i][j] = v[k++];
00183       me[j][i] =  me[i][j];
00184    }
00185 }

double matvec::GeneticDist::get_distance const unsigned    c,
const unsigned    l
 

Definition at line 278 of file geneticdist.cpp.

References chromosome, matvec::LocusStruct::distance, matvec::ChromStruct::locus, matvec::ChromStruct::nloci(), and numchrom.

Referenced by matvec::Population::buildRecombinationMatrix(), matvec::Population::descent_graph_setup(), and matvec::Model::multipoint_Rec_table().

00279 {
00280    if (c < 1 || c>numchrom || l < 1 || l> chromosome[c-1].nloci()) throw exception(" GeneticDist.get_distance(): bad args");
00281    LocusStruct *L = &(chromosome[c-1].locus[l-1]);
00282    return (L->distance);
00283 }

void matvec::GeneticDist::locus const unsigned    c,
const unsigned    l,
const char    qm[],
const unsigned    na,
Vector< double >    allele_freq
 

Definition at line 305 of file geneticdist.cpp.

References matvec::LocusStruct::allele_freq, chromosome, matvec::LocusStruct::genotypic_val_mat, matvec::ChromStruct::locus, matvec::LocusStruct::nallele(), matvec::ChromStruct::nloci(), numchrom, matvec::LocusStruct::qtl_ml, matvec::Vector< double >::resize(), and matvec::Matrix< double >::resize().

00307 {
00308         //      std::cout << "V " << c << " " << l << " " << na << std::endl;
00309   if (c < 1 || c>numchrom || l < 1 || l> chromosome[c-1].nloci()) throw exception("GeneticDist::locus(): bad args");
00310   LocusStruct *L = &(chromosome[c-1].locus[l-1]);
00311   
00312   //RLF modified block
00313   if (strcmp(qm,"qtl")==0) {
00314     L->qtl_ml='q';
00315     L->genotypic_val_mat.resize(na,na);
00316   }
00317   // next else if added by LRT
00318   else if(strcmp(qm,"recessiveLocus")==0) { 
00319     L->qtl_ml='r';
00320   }
00321   else  {
00322     L->qtl_ml = 'm';
00323   }
00324   L->nallele(na);
00325   L->allele_freq.resize(na);
00326   //RLF modified block
00327   //   va_list param_pt;
00328   //   va_start(param_pt,na);
00329   double sumf = 0.0, temp=0.0;
00330   for (int i=0;i<na; i++) {
00331     temp=init_freqs[i];
00332     sumf += temp;
00333     L->allele_freq[i] = temp;
00334     //     std::cout << i << " freq " << temp << " Sumf " << sumf << std::endl;
00335   }
00336   //   va_end(param_pt);
00337   if (fabs(sumf-1.0) > 1.0e-10) throw exception("GeneticDist::locus(): allele_freq does not sum to 1.0");
00338 }

void matvec::GeneticDist::locus const unsigned    c,
const unsigned    l,
const char    qm[],
const unsigned    na,
...   
 

Definition at line 128 of file geneticdist.cpp.

References matvec::LocusStruct::allele_freq, chromosome, matvec::LocusStruct::genotypic_val_mat, matvec::ChromStruct::locus, matvec::LocusStruct::nallele(), matvec::ChromStruct::nloci(), numchrom, numMarkerLoci, matvec::LocusStruct::qtl_ml, matvec::Vector< double >::resize(), and matvec::Matrix< double >::resize().

00130 {
00131    if (c < 1 || c>numchrom || l < 1 || l> chromosome[c-1].nloci()) throw exception("GeneticDist::locus(): bad args");
00132    LocusStruct *L = &(chromosome[c-1].locus[l-1]);
00133    
00134    //RLF modified block
00135    if (strcmp(qm,"qtl")==0) {
00136      L->qtl_ml='q';
00137      L->genotypic_val_mat.resize(na,na);
00138    }
00139    // next else if added by LRT
00140    else if(strcmp(qm,"recessiveLocus")==0) { 
00141      L->qtl_ml='r';
00142    }
00143    else {
00144      L->qtl_ml = 'm';
00145      numMarkerLoci++;
00146    }
00147    L->nallele(na);
00148    L->allele_freq.resize(na);
00149 //RLF modified block
00150    va_list param_pt;
00151    va_start(param_pt,na);
00152    double sumf = 0.0;
00153    for (int i=0;i<na; i++) sumf += L->allele_freq[i] = va_arg(param_pt,double);
00154    va_end(param_pt);
00155    if (fabs(sumf-1.0) > 1.0e-10) throw exception("GeneticDist::locus(): allele_freq does not sum to 1.0");
00156 }

void matvec::GeneticDist::multi_loci int    num_loci
 

Definition at line 285 of file geneticdist.cpp.

References chromosome, matvec::ChromStruct::resize(), and resize().

00286 {
00287 
00288    resize(1);
00289 //   cout << "in GeneticDist::multi_loci: numtrait = " << numtrait<< endl;
00290    chromosome[0].resize(num_loci);
00291 }

unsigned matvec::GeneticDist::nallele const unsigned    c,
const unsigned    l
const [inline]
 

Definition at line 162 of file geneticdist.h.

References matvec::ChromStruct::locus.

00163                            {return chromosome[c].locus[l].nallele();}

const char* matvec::GeneticDist::name void    const [inline]
 

Definition at line 157 of file geneticdist.h.

References distname.

Referenced by matvec::Model::copyfrom(), matvec::Population::input_data(), matvec::Population::input_ped(), and matvec::Model::RSamplerPrior_dist().

00157 {return distname;}

void matvec::GeneticDist::nchrom const unsigned    nc
 

Definition at line 98 of file geneticdist.cpp.

References matvec::check_ptr(), chromosome, and numchrom.

00099 {
00100    if (numchrom == nc) return;
00101    numchrom = nc;
00102    if (chromosome) {
00103      delete [] chromosome;
00104      chromosome=0;
00105    }
00106    if(numchrom>0){
00107      chromosome = new ChromStruct[numchrom];
00108    }
00109    else {
00110      chromosome = 0;
00111    }
00112    check_ptr(chromosome);
00113 }

unsigned matvec::GeneticDist::nchrom void    const [inline]
 

Definition at line 160 of file geneticdist.h.

References numchrom.

Referenced by matvec::Population::build_trans_mat(), matvec::Population::get_genotype_freq(), matvec::Individual::remodel(), matvec::Genome::remodel(), matvec::Population::resize(), and resize().

00160 {return numchrom;}

void matvec::GeneticDist::nloci const unsigned    nl0,
...   
 

Definition at line 115 of file geneticdist.cpp.

References chromosome, numchrom, and matvec::ChromStruct::resize().

00116 {
00117    chromosome[0].resize(nl0);
00118    va_list param_pt;
00119    va_start(param_pt,nl0);
00120    unsigned nl;
00121    for (int i=1;i<numchrom;i++) {
00122       nl = va_arg(param_pt,unsigned);
00123       chromosome[i].resize(nl);
00124    }
00125    va_end(param_pt);
00126 }

unsigned matvec::GeneticDist::nloci_chrom const unsigned    c const [inline]
 

Definition at line 207 of file geneticdist.h.

References chromosome, and matvec::ChromStruct::nloci().

Referenced by matvec::Population::input_descentGraph(), matvec::Population::input_markerData(), and matvec::Population::output_descentGraph().

00208 {
00209    if (c > 0) {
00210       return chromosome[c-1].nloci();
00211    }
00212    else {
00213       std::cerr << "GeneticDist::nloci(c): arg value out of range";
00214       exit(1);
00215    }
00216 }

virtual unsigned matvec::GeneticDist::ntrait void    const [inline, virtual]
 

Reimplemented in matvec::UnknownDist.

Definition at line 154 of file geneticdist.h.

References numtrait.

Referenced by matvec::Individual::remodel(), matvec::Population::resize(), and matvec::Model::RSamplerPrior_dist().

00154 {return numtrait;}

const GeneticDist& matvec::GeneticDist::operator= const GeneticDist &    A [inline]
 

Definition at line 149 of file geneticdist.h.

References copyfrom(), and numchrom.

00149                                                          {numchrom=0;
00150                   chromosome=0; copyfrom(A); return *this;}

void matvec::GeneticDist::put_distance const unsigned    c,
const unsigned    l,
double    distance
 

Definition at line 272 of file geneticdist.cpp.

References chromosome, matvec::LocusStruct::distance, matvec::ChromStruct::locus, matvec::ChromStruct::nloci(), and numchrom.

00273 {
00274    if (c < 1 || c>numchrom || l < 1 || l> chromosome[c-1].nloci()) throw exception("GeneticDist::put_distance() : bad args");
00275    LocusStruct *L = &(chromosome[c-1].locus[l-1]);
00276    L->distance = dist;
00277 }

void matvec::GeneticDist::putColmNames const unsigned    c,
const unsigned    l,
char    nm1[],
char    nm2[]
 

Definition at line 159 of file geneticdist.cpp.

References chromosome, matvec::ChromStruct::locus, matvec::LocusStruct::nameOfcol1, matvec::LocusStruct::nameOfcol2, matvec::ChromStruct::nloci(), and numchrom.

00161 {
00162    if (c < 1 || c>numchrom || l < 1 || l> chromosome[c-1].nloci()) throw exception("GeneticDist::locus(): bad args");
00163    LocusStruct *L = &(chromosome[c-1].locus[l-1]);
00164    L->nameOfcol1 = nm1;
00165    L->nameOfcol2 = nm2;
00166 }

void matvec::GeneticDist::recomb_rate const unsigned    c,
const unsigned    li,
const unsigned    lj,
const double    r
 

Definition at line 220 of file geneticdist.cpp.

References chromosome, matvec::ChromStruct::nloci(), and matvec::ChromStruct::recomb_rate_mat.

00222 {
00223    if (c <= 0) throw exception("GeneticDist.recomb_rate(): out of range");
00224    int n = chromosome[c-1].nloci();
00225    if (li<1 || li>n || lj<1 || lj>n) throw exception("GeneticDist::recomb_rate(): out of range");
00226    chromosome[c-1].recomb_rate_mat[li-1][lj-1] = r;
00227 }

double matvec::GeneticDist::recomb_rate const unsigned    c,
const unsigned    li,
const unsigned    lj
 

Definition at line 210 of file geneticdist.cpp.

References chromosome, and matvec::ChromStruct::recomb_rate_mat.

00212 {
00213    if (c==0 || li==0) throw exception("GeneticDist::recomb_rate(): bad args");
00214    double d=0.0;
00215    unsigned k, ii=li-1;
00216    for (k=li; k<lj; k++) d += chromosome[c-1].recomb_rate_mat[ii][k];
00217    return 0.5*tanh(2.0*d);
00218 }

void matvec::GeneticDist::release void   
 

Definition at line 203 of file geneticdist.cpp.

References chromosome, and numchrom.

Referenced by ~GeneticDist().

00204 {
00205    if (chromosome) {
00206       delete [] chromosome; chromosome = 0; numchrom = 0;
00207    }
00208 }

virtual void matvec::GeneticDist::resize const unsigned    nc [inline, virtual]
 

Reimplemented in matvec::UnknownDist.

Definition at line 153 of file geneticdist.h.

References nchrom().

Referenced by copyfrom(), GeneticDist(), and multi_loci().

00153 {nchrom(nc); }

double matvec::GeneticDist::sample void    const [inline]
 

Definition at line 183 of file geneticdist.h.

00183 {return 0.0;}

virtual doubleMatrix* matvec::GeneticDist::var_matrix void    [inline, virtual]
 

Reimplemented in matvec::UnknownDist.

Definition at line 155 of file geneticdist.h.

Referenced by matvec::GLMM::getVarEstimates(), matvec::Model::info(), matvec::GLMM::info(), and matvec::ModelTerm::variance().

00155 { return 0;}


Member Data Documentation

ChromStruct* matvec::GeneticDist::chromosome
 

Definition at line 142 of file geneticdist.h.

Referenced by copyfrom(), matvec::Population::countGenotypes(), display(), matvec::Population::displayGenotypeFrequencies(), GeneticDist(), genotypic_val(), get_distance(), matvec::Population::initGenotypeFreq(), locus(), multi_loci(), nchrom(), nloci(), nloci_chrom(), put_distance(), putColmNames(), recomb_rate(), and release().

char matvec::GeneticDist::distname[25] [protected]
 

Definition at line 137 of file geneticdist.h.

Referenced by matvec::UnknownDist::copyfrom(), copyfrom(), GeneticDist(), name(), and matvec::UnknownDist::UnknownDist().

unsigned matvec::GeneticDist::numchrom [protected]
 

Definition at line 138 of file geneticdist.h.

Referenced by copyfrom(), GeneticDist(), genotypic_val(), get_distance(), locus(), nchrom(), nloci(), operator=(), put_distance(), putColmNames(), and release().

unsigned matvec::GeneticDist::numMarkerLoci
 

Definition at line 143 of file geneticdist.h.

Referenced by copyfrom(), GeneticDist(), matvec::Population::input_markerData(), and locus().

unsigned matvec::GeneticDist::numtrait [protected]
 

Definition at line 138 of file geneticdist.h.

Referenced by copyfrom(), display(), GeneticDist(), and ntrait().

SafeSTLVector<MaternalPaternalRQTLAlleles> matvec::GeneticDist::rqtlVector
 

Definition at line 191 of file geneticdist.h.


The documentation for this class was generated from the following files:
Generated on Thu Jun 16 17:14:22 2005 for Matvec by doxygen1.2.16