#include <geneticdist.h>
Inheritance diagram for matvec::UnknownDist:

Definition at line 224 of file geneticdist.h.
Public Methods | |
| UnknownDist (void) | |
| UnknownDist (const UnknownDist &u) | |
| UnknownDist (const Vector< double > mu, const doubleMatrix sigma) | |
| UnknownDist (const double mu, const double sigma) | |
| ~UnknownDist (void) | |
| void | copyfrom (const UnknownDist &A) |
| void | resize (const unsigned n) |
| unsigned | ntrait (void) const |
| Vector< double > * | mean_vector (void) |
| doubleMatrix * | var_matrix (void) |
| const char * | name (void) const |
| ChromStruct * | chrom (void) |
| double | recomb_rate (const unsigned c, const unsigned li, const unsigned lj) |
| void | recomb_rate (const unsigned c, const unsigned li, const unsigned lj, const double r) |
| unsigned | nchrom (void) const |
| void | nchrom (const unsigned nc) |
| 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 | nloci (const unsigned nl0,...) |
| void | release (void) |
| void | locus (const unsigned c, const unsigned l, const char qm[], const unsigned na,...) |
| void | locus (const unsigned c, const unsigned l, const char qm[], const unsigned na, Vector< double > allele_freq) |
| void | putColmNames (const unsigned c, const unsigned l, char nm1[], char nm2[]) |
| void | genotypic_val (const unsigned c, const unsigned l, const double *v) |
| void | genotypic_val (const unsigned c, const unsigned l, const double v0,...) |
| const double ** | genotypic_val (const unsigned c, const unsigned l) const |
| double | sample (void) 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) |
Public Attributes | |
| ChromStruct * | chromosome |
| unsigned | numMarkerLoci |
| SafeSTLVector< MaternalPaternalRQTLAlleles > | rqtlVector |
Protected Attributes | |
| unsigned | dim |
| Vector< double > | mu_vec |
| doubleMatrix | var_mat |
| char | distname [25] |
| unsigned | numchrom |
| unsigned | numtrait |
|
|
Definition at line 231 of file geneticdist.h. References dim, and matvec::GeneticDist::distname.
|
|
|
Definition at line 232 of file geneticdist.h. References copyfrom().
00232 :GeneticDist() {copyfrom(u);} |
|
||||||||||||
|
Definition at line 231 of file geneticdist.cpp. References dim, matvec::GeneticDist::distname, mu_vec, matvec::Matrix< double >::num_rows(), matvec::doubleMatrix::psd(), matvec::Vector< double >::size(), var_mat, and matvec::warning().
00232 {
00233 mu_vec = mu;
00234 dim = mu_vec.size();
00235 if (sigma.psd()) {
00236 if (dim == sigma.num_rows()) {
00237 var_mat = sigma;
00238 } else {
00239 warning(" UnknownDist(u,V): u and V incompatible");
00240 }
00241 } else {
00242 warning(" UnknownDist(u,V): V must be psd ");
00243 }
00244 strcpy(distname,"Unknown");
00245 }
|
|
||||||||||||
|
Definition at line 246 of file geneticdist.cpp. References matvec::GeneticDist::distname, mu_vec, resize(), and var_mat.
|
|
|
Definition at line 235 of file geneticdist.h.
00235 {;}
|
|
|
|
Definition at line 87 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, matvec::GeneticDist::distname, matvec::GeneticDist::numchrom, matvec::GeneticDist::numMarkerLoci, matvec::GeneticDist::numtrait, and matvec::GeneticDist::resize(). Referenced by matvec::GeneticDist::GeneticDist(), and matvec::GeneticDist::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 }
|
|
|
Definition at line 254 of file geneticdist.cpp. References dim, matvec::GeneticDist::distname, mu_vec, and var_mat. Referenced by matvec::Model::copyfrom(), and UnknownDist().
|
|
|
Definition at line 293 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, matvec::ChromStruct::nloci(), and matvec::GeneticDist::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 }
|
|
||||||||||||
|
Definition at line 194 of file geneticdist.h. References matvec::GeneticDist::chromosome, and matvec::ChromStruct::locus.
00196 {
00197 return (const double**)chromosome[c].locus[l].genotypic_val_mat.begin();
00198 }
|
|
||||||||||||||||||||
|
Definition at line 187 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, matvec::ChromStruct::locus, matvec::ChromStruct::nloci(), and matvec::GeneticDist::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 }
|
|
||||||||||||||||
|
Definition at line 169 of file geneticdist.cpp. References matvec::GeneticDist::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 }
|
|
||||||||||||
|
Definition at line 278 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, matvec::LocusStruct::distance, matvec::ChromStruct::locus, matvec::ChromStruct::nloci(), and matvec::GeneticDist::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 }
|
|
||||||||||||||||||||||||
|
Definition at line 305 of file geneticdist.cpp. References matvec::LocusStruct::allele_freq, matvec::GeneticDist::chromosome, matvec::LocusStruct::genotypic_val_mat, matvec::ChromStruct::locus, matvec::LocusStruct::nallele(), matvec::ChromStruct::nloci(), matvec::GeneticDist::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 }
|
|
||||||||||||||||||||||||
|
Definition at line 128 of file geneticdist.cpp. References matvec::LocusStruct::allele_freq, matvec::GeneticDist::chromosome, matvec::LocusStruct::genotypic_val_mat, matvec::ChromStruct::locus, matvec::LocusStruct::nallele(), matvec::ChromStruct::nloci(), matvec::GeneticDist::numchrom, matvec::GeneticDist::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 }
|
|
|
Definition at line 241 of file geneticdist.h.
00241 {return &mu_vec;}
|
|
|
Definition at line 285 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, matvec::ChromStruct::resize(), and matvec::GeneticDist::resize().
00286 {
00287
00288 resize(1);
00289 // cout << "in GeneticDist::multi_loci: numtrait = " << numtrait<< endl;
00290 chromosome[0].resize(num_loci);
00291 }
|
|
||||||||||||
|
Definition at line 162 of file geneticdist.h. References matvec::ChromStruct::locus.
00163 {return chromosome[c].locus[l].nallele();}
|
|
|
Definition at line 157 of file geneticdist.h. References matvec::GeneticDist::distname. Referenced by matvec::Model::copyfrom(), matvec::Population::input_data(), matvec::Population::input_ped(), and matvec::Model::RSamplerPrior_dist().
00157 {return distname;}
|
|
|
Definition at line 98 of file geneticdist.cpp. References matvec::check_ptr(), matvec::GeneticDist::chromosome, and matvec::GeneticDist::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 }
|
|
|
Definition at line 160 of file geneticdist.h. References matvec::GeneticDist::numchrom. Referenced by matvec::Population::build_trans_mat(), matvec::Population::get_genotype_freq(), matvec::Individual::remodel(), matvec::Genome::remodel(), matvec::Population::resize(), and matvec::GeneticDist::resize().
00160 {return numchrom;}
|
|
||||||||||||
|
Definition at line 115 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, matvec::GeneticDist::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 }
|
|
|
Definition at line 207 of file geneticdist.h. References matvec::GeneticDist::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 }
|
|
|
Reimplemented from matvec::GeneticDist. Definition at line 239 of file geneticdist.h. References dim.
00239 {return dim;}
|
|
||||||||||||||||
|
Definition at line 272 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, matvec::LocusStruct::distance, matvec::ChromStruct::locus, matvec::ChromStruct::nloci(), and matvec::GeneticDist::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 }
|
|
||||||||||||||||||||
|
Definition at line 159 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, matvec::ChromStruct::locus, matvec::LocusStruct::nameOfcol1, matvec::LocusStruct::nameOfcol2, matvec::ChromStruct::nloci(), and matvec::GeneticDist::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 }
|
|
||||||||||||||||||||
|
Definition at line 220 of file geneticdist.cpp. References matvec::GeneticDist::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 }
|
|
||||||||||||||||
|
Definition at line 210 of file geneticdist.cpp. References matvec::GeneticDist::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 }
|
|
|
Definition at line 203 of file geneticdist.cpp. References matvec::GeneticDist::chromosome, and matvec::GeneticDist::numchrom. Referenced by matvec::GeneticDist::~GeneticDist().
00204 {
00205 if (chromosome) {
00206 delete [] chromosome; chromosome = 0; numchrom = 0;
00207 }
00208 }
|
|
|
Reimplemented from matvec::GeneticDist. Definition at line 263 of file geneticdist.cpp. References dim, mu_vec, matvec::Matrix< double >::resize(), matvec::Vector< double >::resize(), and var_mat. Referenced by UnknownDist().
|
|
|
Definition at line 183 of file geneticdist.h.
00183 {return 0.0;}
|
|
|
Reimplemented from matvec::GeneticDist. Definition at line 242 of file geneticdist.h.
00242 {return &var_mat;}
|
|
|
|
Definition at line 226 of file geneticdist.h. Referenced by copyfrom(), ntrait(), resize(), and UnknownDist(). |
|
|
Definition at line 137 of file geneticdist.h. Referenced by copyfrom(), matvec::GeneticDist::copyfrom(), matvec::GeneticDist::GeneticDist(), matvec::GeneticDist::name(), and UnknownDist(). |
|
|
Definition at line 227 of file geneticdist.h. Referenced by copyfrom(), resize(), and UnknownDist(). |
|
|
Definition at line 138 of file geneticdist.h. Referenced by matvec::GeneticDist::copyfrom(), matvec::GeneticDist::GeneticDist(), matvec::GeneticDist::genotypic_val(), matvec::GeneticDist::get_distance(), matvec::GeneticDist::locus(), matvec::GeneticDist::nchrom(), matvec::GeneticDist::nloci(), matvec::GeneticDist::operator=(), matvec::GeneticDist::put_distance(), matvec::GeneticDist::putColmNames(), and matvec::GeneticDist::release(). |
|
|
Definition at line 143 of file geneticdist.h. Referenced by matvec::GeneticDist::copyfrom(), matvec::GeneticDist::GeneticDist(), matvec::Population::input_markerData(), and matvec::GeneticDist::locus(). |
|
|
Definition at line 138 of file geneticdist.h. Referenced by matvec::GeneticDist::copyfrom(), matvec::GeneticDist::display(), matvec::GeneticDist::GeneticDist(), and matvec::GeneticDist::ntrait(). |
|
|
Definition at line 191 of file geneticdist.h. |
|
|
Definition at line 228 of file geneticdist.h. Referenced by copyfrom(), resize(), and UnknownDist(). |
1.2.16