Conversation
|
Checks still failing, @YagmurSimsekk |
|
The error says "unable to find version |
There was a problem hiding this comment.
Good initial material.
It seems that in many places the already existing functionality from mia & miaViz can be used, avoiding reinventing the wheel and replacing those with less thoroughly tested code.
I suggest @YagmurSimsekk and @TuomasBorman could have a look at this as part of their miaSim contributions when his schedule will allow.
| # makePlot(simulation_GLV[[scenario]][[row]][[local_community]]$matrix) | ||
| dfs_to_bind[[scenario]] <- append(dfs_to_bind[[scenario]], list(simulation_GLV[[scenario]][[row]][[local_community]]$matrix[time = 1000, ])) | ||
| } | ||
|
|
||
| ### form otu tables #### | ||
| otu_table[[scenario]][[row]] <- bind_rows(dfs_to_bind[[scenario]]) | ||
| otu_table[[scenario]][[row]] <- subset(otu_table[[scenario]][[row]], select = -time) | ||
| otu_table[[scenario]][[row]][is.na(otu_table[[scenario]][[row]])] <- 0 | ||
|
|
||
| ### calculate jensen-shannon distance and plot PCoA #### | ||
| jsd[[scenario]][[row]] <- JSD(as.matrix(otu_table[[scenario]][[row]])) | ||
| PCoA[[scenario]][[row]] <- ape::pcoa(as.dist(jsd[[scenario]][[row]])) | ||
| PCoA_coord[[scenario]][[row]] <- PCoA[[scenario]][[row]]$vectors[, 1:2] | ||
| colnames(PCoA_coord[[scenario]][[row]]) <- c("PCo1", "PCo2") | ||
|
|
||
| bestk[[scenario]][[row]] <- 2 | ||
| PAM[[scenario]][[row]] <- pam(PCoA[[scenario]][[row]]$vectors, k = 2) | ||
| SI[[scenario]][[row]] <- PAM[[scenario]][[row]]$silinfo$avg.width | ||
|
|
||
| for (k in 3:10) { | ||
| PAMtemp <- pam(PCoA[[scenario]][[row]]$vectors, k = k) | ||
| if (PAMtemp$silinfo$avg.width > SI[[scenario]][[row]]) { | ||
| SI[[scenario]][[row]] <- PAMtemp$silinfo$avg.width | ||
| bestk[[scenario]][[row]] <- k | ||
| PAM[[scenario]][[row]] <- PAMtemp | ||
| } | ||
| } | ||
|
|
||
| groups[[scenario]][[row]] <- factor(PAM[[scenario]][[row]]$clustering) | ||
|
|
||
| dataframe_pcoa <- as.data.frame(PCoA_coord[[scenario]][[row]]) | ||
| dataframe_pcoa$group <- groups[[scenario]][[row]] | ||
| pcoa_plot[[scenario]][[row]] <- ggplot( | ||
| dataframe_pcoa, | ||
| aes(x = PCo1, y = PCo2, color = group) | ||
| ) + | ||
| ggtitle(paste("scenario", scenario, scenarios[scenario], ";", "alpha =", params$alpha[[row]])) + | ||
| geom_point() + | ||
| # coord_fixed(xlim = c(-1, 1), ylim = c(-1, 1)) + | ||
| theme_bw() + | ||
| scale_color_manual(values = customPalette) + | ||
| theme(legend.position = "none", plot.title = element_text(hjust = 0.5)) | ||
| print(pcoa_plot[[scenario]][[row]]) | ||
| } | ||
|
|
||
| ``` |
There was a problem hiding this comment.
This part could be using more extensively the readily available functionality from mia, miaTime, miaViz.
That could simpilify the implementation considerably.
@TuomasBorman could you have a look as part of contribution to miaSim manuscript? I can recheck afterwards if there are further suggestions.
vignettes/caseStudy1-SIS.Rmd
Outdated
| for (row in seq_len(nrow(params))) { | ||
| pcoa_plot_sis[[row]] <- ggplot(as.data.frame(PCoA_coord[[1]][[row]]), aes(x = PCo1, y = PCo2)) + | ||
| geom_point(aes(color = group_sis[[row]])) + | ||
| ggtitle(paste("alpha =", params$alpha[[row]])) + | ||
| theme_bw() + | ||
| theme(plot.title = element_text(hjust = 0.5)) | ||
| print(pcoa_plot_sis[[row]]) | ||
|
|
||
| # ggsave(paste0("pcoa_validation_", params$alpha[row], ".pdf"), plot = pcoa_plot_sis[[row]], dpi = 300, width = 6, height = 6, units = "cm") |
There was a problem hiding this comment.
Same, could we just use plotReducedDim functions?
| @@ -0,0 +1,443 @@ | |||
| --- | |||
| title: "caseStudy2-NutrientThreshold" | |||
There was a problem hiding this comment.
It might be that the Rmd files should be in folder vignettes/articles/ in order to be shown on the pkg homepage. Not sure. To check.
| author: | ||
| - name: Yu Gao | ||
| email: gaoyu19920914@gmail.com | ||
| - name: Daniel Rios Garza | ||
| email: danielrios.garza@kuleuven.be | ||
| - name: Karoline Faust | ||
| email: karoline.faust@kuleuven.be | ||
| - name: Yagmur Simsek | ||
| email: yagmur.simsek@hsrw.org | ||
| - name: Emma Gheysen | ||
| email: emma.gheysen@student.kuleuven.be | ||
| - name: Leo Lahti | ||
| email: leo.lahti@iki.fi |
There was a problem hiding this comment.
Re: author list - how about just citing the miaSim package landing page which has up-to-date author list? This would help to avoid replicating the same info in multiple places. Just a suggestion.
| gradient.df.generator <- function(n_row, n_col, density_row, max_gradient, error_interval){ | ||
| list_initial <- list() | ||
| dissimilarity.gradient <- seq(from = 0, to = max_gradient, length.out = n_row) | ||
| for (i in seq_len(n_row)){ | ||
| print(i) | ||
| if (i == 1){ | ||
| row_temp <- rbeta(n_col, 1, 1/n_col) | ||
| col_to_remove <- sample(x = seq_len(n_col), size = n_col-n_col*density_row) | ||
| row_temp[col_to_remove] <- 0 | ||
| list_initial[[i]] <- row_temp | ||
| } else { | ||
| while (length(list_initial) < i) { | ||
| row_temp <- rbeta(n_col, 1, 1/n_col) | ||
| col_to_remove <- sample(x = seq_len(n_col), size = n_col-n_col*density_row) | ||
| row_temp[col_to_remove] <- 0 | ||
| diff_temp <- abs(vegdist(rbind(list_initial[[1]], row_temp), method = "bray") - dissimilarity.gradient[i]) | ||
| if (diff_temp < error_interval) { | ||
| list_initial[[i]] <- row_temp | ||
| } | ||
| } | ||
| } | ||
| } | ||
| dataframe_to_return <- as.data.frame(t(matrix(unlist(list_initial), ncol = n_row))) | ||
| return(dataframe_to_return) | ||
| } |
There was a problem hiding this comment.
The first impression is that it might be possible to simplify this considerably but I am not sure?
|
|
||
| ``` | ||
|
|
||
| ## make umap plots |
There was a problem hiding this comment.
same here, use miaViz and related
| n_rep <- 50 | ||
| ``` | ||
|
|
||
| ## initial the output dataframes to store data |
|
|
||
| ## generating function | ||
|
|
||
| this function generates a data frame, where each row is arranged in an increasing dissimilarity to the first row. |
There was a problem hiding this comment.
this is shared with another vignette page; would it make sense to just add this in miaSim package in order to simplify the vignette example? This part is taking now perhaps catching attention from other more central aspects?
| t_end = 1000, | ||
| t_step = 1, | ||
| t_store = 1000) | ||
| CRMspecies <- getCommunity(CRMtest) |
There was a problem hiding this comment.
getCommunity should be replaces with mia functionality
| p_fig2_result_df <- ggplot(result_df, aes(x = n_resources, y = value, group = n_resources)) + | ||
| geom_boxplot(outlier.shape = NA) + | ||
| geom_jitter(alpha = 0.2, width = 0.2) + | ||
| facet_grid(. ~ factor(n_species, levels = n_species_types)) + | ||
| theme_bw() + | ||
| scale_x_continuous(trans = "log2", breaks = n_resources_types) + | ||
| xlab("number of resources") + | ||
| ylab("growth yield (number of individuals)") | ||
| p_fig2_result_df |
There was a problem hiding this comment.
is it possible to use miaViz here?
|
miaSimShiny link was added to README.md |
|
Ok this failed the checks so I went to see in more detail. Changes:
Additional updates will be neeeded but easier to do after this PR is merged. Later PRs should be more compact in size so that the process stays more manageable. |
|
Ok - I had to skip vignette fixes for now to get this through. Much of the fixes would require the new features that are only available after the merge. Let's take note on the PR comments later. |
No description provided.