Haplo Prediction
predict haplogroups
|
00001 /* 00002 * This work is licensed under a Creative Commons 00003 * Attribution-Noncommercial-Share Alike 3.0 United States License. 00004 * 00005 * http://creativecommons.org/licenses/by-nc-sa/3.0/us/ 00006 * 00007 * You are free: 00008 * 00009 * to Share - to copy, distribute, display, and perform the work 00010 * to Remix - to make derivative works 00011 * 00012 * Under the following conditions: 00013 * 00014 * Attribution. You must attribute the work in the manner specified by the 00015 * author or licensor (but not in any way that suggests that they endorse you 00016 * or your use of the work). 00017 * 00018 * Noncommercial. You may not use this work for commercial purposes. 00019 * 00020 * Share Alike. If you alter, transform, or build upon this work, you may 00021 * distribute the resulting work only under the same or similar license to 00022 * this one. 00023 * 00024 * For any reuse or distribution, you must make clear to others the license 00025 * terms of this work. The best way to do this is by including this header. 00026 * 00027 * Any of the above conditions can be waived if you get permission from the 00028 * copyright holder. 00029 * 00030 * Apart from the remix rights granted under this license, nothing in this 00031 * license impairs or restricts the author's moral rights. 00032 */ 00033 00034 00046 #ifndef NB_GMM_H 00047 #define NB_GMM_H 00048 00049 00050 #include <config.h> 00051 00052 #include <stdlib.h> 00053 #include <inttypes.h> 00054 00055 #include <jwsc/base/error.h> 00056 #include <jwsc/vector/vector.h> 00057 #include <jwsc/matrix/matrix.h> 00058 #include <jwsc/matblock/matblock.h> 00059 00060 00062 typedef struct 00063 { 00065 uint32_t num_markers; 00066 00068 uint32_t num_components; 00069 00071 Matrix_d*** mu; 00072 00074 Matblock_d*** sigma; 00075 00077 Vector_d*** pi; 00078 00085 Vector_d* priors; 00086 } 00087 NB_gmm_model; 00088 00089 00091 void train_nb_gmm_model 00092 ( 00093 NB_gmm_model** model_out, 00094 const Vector_u32* labels, 00095 const Matrix_i32* markers, 00096 const Vector_d* priors, 00097 uint32_t num_components 00098 ); 00099 00100 00105 Error* predict_label_with_nb_gmm_model 00106 ( 00107 uint32_t* label_out, 00108 double* confidence_out, 00109 const Vector_i32* markers, 00110 const NB_gmm_model* model, 00111 uint32_t order 00112 ); 00113 00114 00119 Error* predict_labels_with_nb_gmm_model 00120 ( 00121 Vector_u32** labels_out, 00122 Vector_d** confidence_out, 00123 const Matrix_i32* markers, 00124 const NB_gmm_model* model 00125 ); 00126 00127 00129 Error* read_nb_gmm_model(NB_gmm_model** model_out, const char* fname); 00130 00131 00133 Error* write_nb_gmm_model(NB_gmm_model* model, const char* fname); 00134 00135 00137 void free_nb_gmm_model(NB_gmm_model* model); 00138 00139 00141 typedef struct NB_gmm_model_node 00142 { 00148 const struct NB_gmm_model_node* parent; 00149 00155 uint32_t parent_label; 00156 00158 uint32_t num_groups; 00159 00165 struct NB_gmm_model_node** subtrees; 00166 00168 Vector_u32* labels; 00169 00171 Vector_u32** altlabels; 00172 00178 Vector_d* priors; 00179 00181 uint32_t num_components; 00182 00184 NB_gmm_model* model; 00185 00187 char* model_fname; 00188 } 00189 NB_gmm_model_node; 00190 00191 00193 typedef NB_gmm_model_node NB_gmm_model_tree; 00194 00195 00197 Error* train_nb_gmm_model_tree 00198 ( 00199 NB_gmm_model_tree** tree_out, 00200 const Vector_u32* labels, 00201 const Matrix_i32* markers, 00202 const char* tree_xml_fname, 00203 const char* tree_dtd_fname 00204 ); 00205 00206 00211 Error* predict_labels_with_nb_gmm_model_tree 00212 ( 00213 Vector_u32** labels_out, 00214 Vector_d** confidence_out, 00215 const Matrix_i32* markers, 00216 const NB_gmm_model_tree* tree, 00217 uint32_t order 00218 ); 00219 00220 00222 Error* read_nb_gmm_model_tree 00223 ( 00224 NB_gmm_model_tree** tree_out, 00225 const char* tree_xml_fname, 00226 const char* tree_dtd_fname, 00227 const char* model_dirname 00228 ); 00229 00230 00232 Error* write_nb_gmm_model_tree 00233 ( 00234 const NB_gmm_model_tree* tree, 00235 const char* model_dirname 00236 ); 00237 00238 00240 void free_nb_gmm_model_tree(NB_gmm_model_tree* tree); 00241 00242 00243 #endif