summarize_and_plot_graph_and_distribution_structure_information = function (PU_spp_pair_indices, cor_or_app_label, all_correct_node_IDs, plot_output_dir, spp_col_name, PU_col_name, presences_col_name)
PU_spp_pair_indices
dim (PU_spp_pair_indices)
1628 2
PU_spp_pair_indices:
PU_ID spp_ID
1 1 1
2 2 1
...
1625 64 813
1626 82 813
1627 54 814
1628 112 814
cor_or_app_label
cor_or_app_label:
"cor"
all_correct_node_IDs
length (all_correct_node_IDs)
122
head (all_correct_node_IDs)
1 2 3 4 5 6
column names
spp_col_name
"spp_ID"
PU_col_name
"PU_ID"
presences_col_name
"freq"
returned value: final_link_counts_for_each_node
final_link_counts_for_each_node:
PU_ID freq
1 1 1
2 2 25
...
compute_network_measures_using_bipartite_package = function (bpm)
bpm
``` dim (bpm) [1] 814 122
bpm [1:4,1:8] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1 1 0 0 0 0 0 0 ... [2,] 0 0 1 1 0 0 0 0 ... [3,] 0 0 0 0 1 1 0 0 ... [4,] 0 0 0 0 0 0 1 1 ... ... ``` - returned value: bipartite_metrics_from_bipartite_package - data frame with one column of unique PU IDs (both empty and non-empty) and a second column containing the number of species occurring on the corresponding PU - column names are "PU_ID" and "freq" - total number of rows in table is the total number of PUs in the problem, both empty and non-empty PUs - Example:
``` bipartite_metrics_from_bipartite_package connectance web_asymmetry links_per_species number_of_compartments [1,] 0.0169207 -0.744086 1.755914 2
compartment_diversity cluster_coefficient nestedness weighted_nestedness
[1,] 1.015475 0.01726264 4.373023 0.3154829
weighted_NODF interaction_strength_asymmetry specialisation_asymmetry
[1,] 0 0 0.5206311
linkage_density weighted_connectance Fisher_alpha Shannon_diversity
[1,] 12.70423 0.01366046 1.717987e+12 7.398174
interaction_evenness Alatalo_interaction_evenness H2 number.of.species.HL
[1,] 0.6445867 1 0 119
number.of.species.LL mean.number.of.shared.partners.HL
[1,] 811 0.1365902
mean.number.of.shared.partners.LL cluster.coefficient.HL cluster.coefficient.LL
[1,] 0.05527089 0.02864849 0.01827332
weighted.cluster.coefficient.HL weighted.cluster.coefficient.LL niche.overlap.HL
[1,] 0.01722157 0.3061294 0.006840523
niche.overlap.LL togetherness.HL togetherness.LL C.score.HL C.score.LL V.ratio.HL
[1,] 0.02669537 0.004202092 0.01122122 0.9788591 0.9584458 9.688273
V.ratio.LL discrepancy.HL discrepancy.LL extinction.slope.HL extinction.slope.LL
[1,] 0.1657092 1563 1565 5.53822 1.934873
robustness.HL robustness.LL functional.complementarity.HL
[1,] 0.8232885 0.6583167 461.6131
functional.complementarity.LL partner.diversity.HL partner.diversity.LL
[1,] 1031.04 3.019578 0.7403126 generality.HL vulnerability.LL [1,] 23.23393 2.174525
```
compute_igraph_related_network_measures <- function ( num_spp, num_PUs, PU_spp_pair_indices, emulatingTzar, DEBUG_LEVEL, network_output_dir, # cor_num_PUs, # app_ ??? # cor_num_spp, PU_col_name, spp_col_name )
dim (PU_spp_pair_indices)
1628 2
PU_spp_pair_indices:
PU_ID spp_ID
1 1 1
2 2 1
...
1625 64 813
1626 82 813
1627 54 814
1628 112 814
"/Users/bill/tzar/outputdata/biodivprobgen/default_runset/1165_marxan_simulated_annealing.inprogress/Networks"
PU_col_name
"PU_ID"
spp_col_name
"spp_ID"
bipartite_metrics_from_igraph_package_df
ig_top ig_bottom ig_num_edges_m ig_ktop ig_kbottom ig_bidens ig_lcctop ig_lccbottom ig_distop ig_disbottom ig_cctop ig_ccbottom ig_cclowdottop
1 814 122 1633 2.006143 13.38525 0.01644379 810 118 4.342801 4.405056 0.3403602 0.03887111 0.5983846
ig_cclowdotbottom ig_cctopdottop ig_cctopdotbottom ig_mean_bottom_bg_redundancy ig_median_bottom_bg_redundancy ig_mean_top_bg_redundancy
1 0.3004119 0.45096 0.05012125 0.07886978 0 0.01429777
ig_median_top_bg_redundancy
1 0
HAVEN'T DECODED THIS ONE YET. JUST LEAVING HERE WHAT I HAD CUT OUT OF THE CODE TO TRY TO FIGURE OUT WHETHER THERE SHOULD BE app_num_spp AND app_num_PUs AND WHAT WERE PU_spp_pair_names AND PU_spp_pair_names_triple.
REMEMBER THAT THE KEY IS THE FLAGGING OF top AND bottom. THEY ARE THE THINGS THAT INDICATE THE FACT THAT THIS IS A BIPARTITE NETWORK. THE True AND False VALUES IN THE VERTICES type INDICATE WHETHER A NODE IS PART OF THE top OR bottom HALF OF THE BIPARTITE NETWORK. PUs ARE top? SPECIES ARE bottom?
PU_spp_pair_names_triple = create_PU_spp_pair_names (cor_num_PUs, # app_ ??? cor_num_spp, # app_ ??? PU_spp_pair_indices, # app_ ??? PU_col_name, spp_col_name )
PU_spp_pair_names = PU_spp_pair_names_triple$PU_spp_pair_names PU_vertex_names = PU_spp_pair_names_triple$PU_vertex_names spp_vertex_names = PU_spp_pair_names_triple$spp_vertex_names # ... vertices = data.frame (name=c(spp_vertex_names, PU_vertex_names), type=c(rep(FALSE, num_spp), rep(TRUE, num_PUs))) bg = graph.data.frame (PU_spp_pair_names, directed=FALSE, vertices=vertices) bgp = bipartite.projection (bg) bgp_proj1_PUs = bgp$proj1 bgp_proj2_spp = bgp$proj2 head(bg) 6 x 936 sparse Matrix of class "dgCMatrix" [[ suppressing 936 column names ‘s1’, ‘s2’, ‘s3’ ... ]] s1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... s1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s1 . . . . . . . . . . . . . . . 1 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s2 . . . . . . . . . . . . . . . . . 1 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . s3 . . . . . . . . . . . . . . . . . . . 1 1 . . . . . . . . . . . . . . . . 1 . . . . . . . . . s4 . . . . . . . . . . . . . . . . . . . . . 1 1 . . . . . . . . . . . . . . . . . . . . . . . . s5 . . . . . . . . . . . . . . . . . . . . . . . 1 1 . . . . . . . . . . . . . . . . . . . . . . s6 . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 . . . . . . . . . . . . . . . . . . . . s1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # Number of top and bottom nodes top <- length(V(bg)[type==FALSE]) bottom <- length(V(bg)[type==TRUE]) vertices name type 1 s1 FALSE 2 s2 FALSE 3 s3 FALSE 4 s4 FALSE 5 s5 FALSE 6 s6 FALSE 7 s7 FALSE 8 s8 FALSE 9 s9 FALSE 10 s10 FALSE ... 810 s810 FALSE 811 s811 FALSE 812 s812 FALSE 813 s813 FALSE 814 s814 FALSE 815 p1 TRUE 816 p2 TRUE 817 p3 TRUE 818 p4 TRUE 819 p5 TRUE 820 p6 TRUE 821 p7 TRUE 822 p8 TRUE 823 p9 TRUE 824 p10 TRUE ... 929 p115 TRUE 930 p116 TRUE 931 p117 TRUE 932 p118 TRUE 933 p119 TRUE 934 p120 TRUE 935 p121 TRUE 936 p122 TRUE
marxan_control_values = set_up_for_and_run_marxan ( app_PU_spp_pair_indices, PU_col_name, spp_col_name, current_os, marxan_input_dir, marxan_output_dir, parameters, marxan_IO_dir ) )
dim (PU_spp_pair_indices)
1628 2
PU_spp_pair_indices:
PU_ID spp_ID
1 1 1
2 2 1
...
1625 64 813
1626 82 813
1627 54 814
1628 112 814
PU_col_name
"PU_ID"
spp_col_name
"spp_ID"
derived_bdpg_parameters$marxan_IO_dir
cor_or_app_label
cor_or_app_label: "cor"
retVal = list () retVal$marxan_PROP = marxan_PROP retVal$marxan_RANDSEED = marxan_RANDSEED retVal$marxan_NUMREPS = marxan_NUMREPS retVal$marxan_NUMITNS = marxan_NUMITNS retVal$marxan_STARTTEMP = marxan_STARTTEMP retVal$marxan_NUMTEMP = marxan_NUMTEMP retVal$marxan_COSTTHRESH = marxan_COSTTHRESH retVal$marxan_THRESHPEN1 = marxan_THRESHPEN1 retVal$marxan_THRESHPEN2 = marxan_THRESHPEN2 retVal$marxan_RUNMODE = marxan_RUNMODE retVal$marxan_MISSLEVEL = marxan_MISSLEVEL retVal$marxan_ITIMPTYPE = marxan_ITIMPTYPE retVal$marxan_HEURTYPE = marxan_HEURTYPE retVal$marxan_CLUMPTYPE = marxan_CLUMPTYPE
spf_const = write_network_to_marxan_files ( app_PU_spp_pair_indices, PU_col_name, spp_col_name, parameters, marxan_input_dir, marxan_output_dir )
marxan_control_values = set_marxan_controls_and_run_marxan (current_os, marxan_input_dir, marxan_output_dir, parameters, marxan_IO_dir)
create_nodes_data_structure = function (tot_num_nodes, num_nodes_per_group, n__num_groups, num_independent_nodes_per_group)
#------------------------------------------------------------ # Build an overall data frame that shows for each node, # its node ID and group ID, plus a flag indicating whether # it's in the dependent set or not. For example, if there # are 3 nodes per group: # # node_ID group_ID dependent_set_member # 1 1 TRUE # 2 1 TRUE # 3 1 FALSE # 4 2 TRUE # 5 2 TRUE # 6 2 FALSE # ... ... ... #------------------------------------------------------------ nodes = data.frame (node_ID = node_IDs, group_ID = group_IDs, dependent_set_member = dependent_set_members)
gen_single_bdprob = function (parameters, bdpg_error_codes, integerize)
retVal$read_Xu_problem_from_file = read_Xu_problem_from_file retVal$PU_spp_pair_indices = PU_spp_pair_indices_sextet$PU_spp_pair_indices retVal$PU_col_name = PU_spp_pair_indices_sextet$PU_col_name retVal$spp_col_name = PU_spp_pair_indices_sextet$spp_col_name retVal$num_PUs = PU_spp_pair_indices_sextet$num_PUs retVal$num_spp = PU_spp_pair_indices_sextet$num_spp retVal$cor_optimum_cost = PU_spp_pair_indices_sextet$correct_solution_cost retVal$PU_costs = PU_costs retVal$derived_Xu_params = derived_Xu_params retVal$prob_is_ok = TRUE retVal$bpm = bpm # 0/1 adjacency matrix of spp rows vs PU cols retVal$nodes = nodes
num_nodes_per_group = derived_Xu_params$num_nodes_per_group num_rounds_of_linking_between_groups = derived_Xu_params$num_rounds_of_linking_between_groups target_num_links_between_2_groups_per_round = derived_Xu_params$target_num_links_between_2_groups_per_round num_links_within_one_group = derived_Xu_params$num_links_within_one_group tot_num_links_inside_groups = derived_Xu_params$tot_num_links_inside_groups max_possible_num_links_between_groups = derived_Xu_params$max_possible_num_links_between_groups max_possible_tot_num_links = derived_Xu_params$max_possible_tot_num_links max_possible_tot_num_node_link_pairs = derived_Xu_params$max_possible_tot_num_node_link_pairs n__num_groups = derived_Xu_params$n__num_groups alpha__ = derived_Xu_params$alpha__ p__prop_of_links_between_groups = derived_Xu_params$p__prop_of_links_between_groups r__density = derived_Xu_params$r__density num_independent_nodes_per_group = derived_Xu_params$num_independent_nodes_per_group num_independent_set_nodes = derived_Xu_params$num_independent_set_nodes tot_num_nodes = derived_Xu_params$tot_num_nodes num_dependent_set_nodes = derived_Xu_params$num_dependent_set_nodes opt_solution_as_frac_of_tot_num_nodes = derived_Xu_params$opt_solution_as_frac_of_tot_num_nodes base_for_target_num_links_between_2_groups_per_round = derived_Xu_params$base_for_target_num_links_between_2_groups_per_round at_least_1_for_target_num_links_between_2_groups_per_round = derived_Xu_params$at_least_1_for_target_num_links_between_2_groups_per_round
nodes = create_nodes_data_structure (tot_num_nodes, num_nodes_per_group, n__num_groups, num_independent_nodes_per_group )
edge_list = create_Xu_graph (num_nodes_per_group, n__num_groups, nodes, max_possible_tot_num_links, target_num_links_between_2_groups_per_round, num_rounds_of_linking_between_groups, DEBUG_LEVEL )
correct_solution_vector_is_known = TRUE
dependent_node_IDs = get_dependent_node_IDs (nodes)
num_PUs = get_num_nodes (nodes)
PU_costs = get_PU_costs (num_PUs)
#------------------------------------------------------------- # Combine the information in the nodes and edge_list data # structures into a single data structure that has one line # for each species on each planning unit (where species # are edges and PUs are nodes). #------------------------------------------------------------- PU_spp_pair_indices_sextet = create_PU_spp_pair_indices (edge_list, nodes, dependent_node_IDs, PU_costs, num_PUs) PU_spp_pair_indices = PU_spp_pair_indices_sextet$PU_spp_pair_indices PU_col_name = PU_spp_pair_indices_sextet$PU_col_name spp_col_name = PU_spp_pair_indices_sextet$spp_col_name num_PUs = PU_spp_pair_indices_sextet$num_PUs num_spp = PU_spp_pair_indices_sextet$num_spp cor_optimum_cost = PU_spp_pair_indices_sextet$correct_solution_cost
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.