def make_pcoa_webgl_string_from_files(pcoa_headers, points, pct_var, map_headers, map_data): """make a WebGL representation of a pcoa plot with the provided data Input: pcoa_headers: list of headers of a pcoa file points: coordinates of a pcoa file map_headers: list of headers for a mapping file map_data: list of lists containing the data of a mapping file Output: webgl_string: string representation of the pcoa plot for WebGL display """ ellipses = {} for h,p in zip(pcoa_headers, points): ellipses[h] = { 'axes_radii': [0.0, 0.0, 0.0], 'center': p[:3] } # check the ellipses are created correctly if ellipses == {}: raise ValueError, 'Could not create PCoA plot' webgl_string = make_pcoa_plot(ellipses, (map_data, map_headers), pct_var[:3]) return webgl_string
def generate_pcoa_cloud_from_point_in_omega(mapping_file_tuple, biom_object, metric, sequences, iterations, axes, tree_object=None): """run the randomisations and get a WebGL PCoA plot string representation Input: mapping_file_tuple: data and headers tuple for representing the mapping file biom_object: otu table biom object metric: string of the name for the beta diversity metric, i. e. 'unifrac' sequences: number of sequences per sample iterations: number of iterations to generate the pcoa plot axes: number of axes to account for tree_object: tree to perform the beta diversity calculation Output: WebGL string representing the PCoA plot """ # get a list of the SampleIds full_id_list = mapping_file_to_dict(mapping_file_tuple[0], mapping_file_tuple[1]).keys() pcoa_list = [] for i in range(iterations): rare_biom_table = get_rare_data(biom_object, sequences) beta_dm = single_object_beta(rare_biom_table, metric, tree_object) pcoa_results = pcoa(beta_dm) pcoa_list.append(pcoa_results) # convert the list of pcoa lines into ellipsoid coords ellipse_coords_by_sampleId, sampleId_to_coords = get_pcoa_ellipsoid_coords(pcoa_list, axes, full_id_list) # check the ellipses are created correctly if type(ellipse_coords_by_sampleId) == type(''): raise ValueError, 'Could not create PCoA plot' webgl_string = make_pcoa_plot(ellipse_coords_by_sampleId, mapping_file_tuple, sampleId_to_coords['variation explained']) return webgl_string