Ajout script pour récupération données
This commit is contained in:
parent
86d902cca9
commit
7783c3de83
1 changed files with 29 additions and 0 deletions
|
|
@ -6,3 +6,32 @@ if ("MicroBioMap" %in% rownames(installed.packages()) == FALSE) {
|
||||||
BiocManager::install("blekhmanlab/MicroBioMap")
|
BiocManager::install("blekhmanlab/MicroBioMap")
|
||||||
}
|
}
|
||||||
library(MicroBioMap)
|
library(MicroBioMap)
|
||||||
|
library(countrycode)
|
||||||
|
library(igraph)
|
||||||
|
library(here)
|
||||||
|
library(readr)
|
||||||
|
setClassUnion("ExpData", c("matrix", "SummarizedExperiment"))
|
||||||
|
cpd <- getCompendium(version = "1.0.1")
|
||||||
|
|
||||||
|
colData(cpd)$country <- countrycode(colData(cpd)$iso, "iso2c", "country.name")
|
||||||
|
|
||||||
|
projects <- unique(colData(cpd)$project)
|
||||||
|
|
||||||
|
save_folder <- here("data")
|
||||||
|
if (!dir.exists(save_folder)) {
|
||||||
|
dir.create(save_folder)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (project in projects) {
|
||||||
|
cat("Processing project:", project, "\n")
|
||||||
|
# Filter the compendium for the current project
|
||||||
|
project_data <- cpd[, colData(cpd)$project == project]
|
||||||
|
matrix_data <- counts(project_data)
|
||||||
|
# Create a graph from the matrix data
|
||||||
|
g <- graph_from_biadjacency_matrix(matrix_data)
|
||||||
|
edge_list <- as_edgelist(g) |> as.data.frame()
|
||||||
|
colnames(edge_list) <- c("source", "target")
|
||||||
|
write_csv(edge_list, file = here(save_folder, paste0(project, "_edge_list.csv.gz")))
|
||||||
|
supinfo_df <- as.data.frame(colData(project_data))
|
||||||
|
write_csv(supinfo_df, file = here(save_folder, paste0(project, "_supinfo.csv.gz")))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue