### Install Dynverse Packages in Dependency Order (R) Source: https://context7.com/dynverse/dynverse/llms.txt This script installs all local dynverse packages in a topologically sorted order based on their dependencies. It requires R and the devtools package. Run from the root of the dynverse monorepo after initializing submodules. ```r # Run from the root of the dynverse monorepo after cloning all submodules: # git submodule update --init --recursive #!/usr/bin/env Rscript library(dplyr, warn.conflicts = FALSE) library(purrr, warn.conflicts = FALSE) library(desc, warn.conflicts = FALSE) library(devtools, warn.conflicts = FALSE) requireNamespace("igraph", quietly = TRUE) setRepositories(ind = 1:4) # include CRAN, Bioconductor, etc. # Discover all DESCRIPTION files (excluding revdep/Rcheck artifacts) files <- list.files(path = ".", pattern = "DESCRIPTION", recursive = TRUE, full.names = TRUE) %>% discard(grepl("revdep|Rcheck", .)) %>% discard(grepl("^ti", .)) # Build a data frame of packages and their inter-dependencies packages <- map_df(files, function(file) { descr <- desc::desc(file = file) tibble( package = descr$get("Package"), version = descr$get("Version"), file = file, dir = gsub("/DESCRIPTION", "", file) ) }) %>% mutate(colour = rainbow(n())) dependencies <- map_df(packages$file, function(file) { descr <- desc::desc(file = file) descr$get_deps() %>% rename(dependency = package) %>% mutate(package = descr$get("Package")) %>% select(package, dependency, version, type) }) dyndependencies <- dependencies %>% inner_join(packages %>% select(package), by = "package") %>% inner_join(packages %>% select(dependency = package), by = "dependency") # Build igraph and resolve topological order depgr <- igraph::graph_from_data_frame(d = dyndependencies, directed = TRUE, vertices = packages) dist <- igraph::distances(depgr, mode = "in") dist[is.infinite(dist)] <- 0 dist[dist > 0] <- 1 if (any(dist * t(dist) > 0)) stop("Circular dependencies detected") selected_ix <- c() to_select_ix <- seq_len(ncol(dist)) while (length(to_select_ix) > 0) { wts <- colSums(dist[to_select_ix, to_select_ix, drop = FALSE]) ix <- which(wts == 0) selected_ix <- c(selected_ix, to_select_ix[ix]) to_select_ix <- to_select_ix[-ix] } ordered_packages <- packages[selected_ix, ] # Install each package without re-installing transitive deps (already done in order) walk(seq_len(nrow(ordered_packages)), function(i) { cat("Installing ", i, "/", nrow(ordered_packages), ": ", ordered_packages$package[[i]], "\n", sep = "") devtools::install(pkg = ordered_packages$dir[[i]], dependencies = FALSE, quiet = TRUE) }) # Expected: sequential console output "Installing 1/18: dynutils", "Installing 2/18: dyneval", ... ``` -------------------------------- ### Build and Run TI Method Container Source: https://context7.com/dynverse/dynverse/llms.txt Standard workflow for containerizing a single TI method using Docker and running it. This involves building the image, interactive debugging, and non-interactive execution on example datasets. ```bash export METHOD=recat cd ../ti_${METHOD} chmod +x run.py run.R example.R # Build the Docker container for this method docker build -t dynverse/ti_${METHOD} . # Interactive shell inside the container for debugging docker run -it --entrypoint bash \ -v $(pwd):/mnt \ dynverse/ti_${METHOD} # Inside the container, run: # R # task <- dyncli::main(c("--dataset", "/mnt/example.h5", "--output", "/mnt/output.h5")) # Run the method non-interactively on an example dataset docker run \ -v $(pwd):/mnt \ dynverse/ti_${METHOD} \ --dataset /mnt/example.h5 \ --output /mnt/output.h5 \ --verbosity 3 # Expected: HDF5 output.h5 written with trajectory model (milestone network, cell positions, etc.) # Clean up output artifacts rm -f output.h5 example.h5 ``` -------------------------------- ### Initialize All Submodules Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Initializes and updates all submodules, including nested ones. ```bash git submodule update --init --recursive ``` -------------------------------- ### Update All Repositories Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Stages all changes, commits them with a message, and pushes to the remote. ```bash git add * git commit -m "updated repositories" git push ``` -------------------------------- ### Generate Package Overview Table Source: https://context7.com/dynverse/dynverse/llms.txt Auto-generates an `overview.md` table by scanning `DESCRIPTION` files in the monorepo to extract package titles and URLs. Requires `tidyverse`, `desc`, and `glue` libraries. ```r # Render from R or via: Rscript -e "rmarkdown::render('overview.Rmd')" library(tidyverse) library(desc) df <- tibble( description_file = list.files(".", pattern = "DESCRIPTION", recursive = TRUE) ) %>% filter(!grepl("revdep|methods/", description_file)) %>% rowwise() %>% mutate( desc = list(desc::desc(description_file)), title = desc$get_field("Title"), url = desc$get_field("URL", NA), package = desc$get_field("Package") ) %>% arrange(package) %>% transmute( Package = glue::glue("[{package}](https://github.com/dynverse/{package})"), Travis = glue::glue("[![Travis](...)](https://travis-ci.org/dynverse/{package})"), Appveyor = glue::glue("[![AppVeyor](...)](https://ci.appveyor.com/project/dynverse/{package})"), Codecov = glue::glue("[![codecov](...)](https://codecov.io/gh/dynverse/{package})"), Description = title ) knitr::kable(df) # Expected: markdown table with one row per dynverse package, CI badges, and description. ``` -------------------------------- ### Manage Git Submodules for Dynverse Methods (Bash) Source: https://context7.com/dynverse/dynverse/llms.txt Standard git commands for managing method submodules within the dynverse repository. These commands are used for initialization, adding new methods, updating existing ones, and checking out specific branches. ```bash # 1. Initialise all submodules after a fresh clone git submodule update --init --recursive ``` ```bash # 2. Add a new TI method as a submodule tracking the devel branch git submodule add -b devel git@github.com:dynverse/mfa.git methods/mfa ``` ```bash # 3. Pull latest commits for every submodule git submodule foreach git pull ``` ```bash # 4. Check out devel branch on every submodule that has one git submodule foreach \ 'if [ `git branch --list devel | wc -l` = 1 ]; \ then git checkout devel; else echo "no devel branch"; fi' ``` -------------------------------- ### Read and Plot TI Method Output Source: https://context7.com/dynverse/dynverse/llms.txt Demonstrates loading an HDF5 trajectory output from any dynverse container and visualizing it using `dynplot::plot_graph()`. Requires `tidyverse` and `dynwrap` libraries. ```r library(tidyverse) method <- "recat" # Create a method definition object from the YAML spec bundled with the container source dynwrap::create_ti_method_definition( paste0("ti_", method, "/definition.yml"), script = "" ) # Read the HDF5 output written by the containerised method traj <- dynutils::read_h5(paste0("ti_", method, "/output.h5")) # Visualise the trajectory topology dynplot::plot_graph(traj) # Expected: ggplot2 graph where nodes are milestones and edges represent transitions, # cells are placed along the edges according to their pseudotime position. ``` -------------------------------- ### Checkout Devel Branches for Submodules Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Checks out the 'devel' branch for each submodule if it exists, after ensuring the main repository is not in a detached state. ```bash git submodule foreach 'if [ `git status | grep detached | wc -l` = 1 ]; then git checkout master; else echo not detached; fi' git submodule foreach 'if [ `git branch --list devel | wc -l` = 1 ]; then git checkout devel; else echo no devel branch; fi' ``` -------------------------------- ### Encrypt File for Travis CI Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Encrypts a file using Travis CI's encryption tool, suitable for securely storing credentials. The encrypted file is then added to the repository. ```bash travis encrypt-file ~/credentials --add ``` -------------------------------- ### Propagate License Files Across All Sub-packages Source: https://context7.com/dynverse/dynverse/llms.txt An Rscript that iterates through all DESCRIPTION files in the monorepo. It copies root LICENSE and LICENSE.md files to packages missing them, updates the License field in DESCRIPTION, and commits/pushes the changes from within each package directory. It also handles bare submodule paths listed in .gitmodules. ```r #!/usr/bin/Rscript library(tidyverse) library(desc) library(fs) descriptions <- list.files(path = ".", pattern = "DESCRIPTION", recursive = TRUE, full.names = TRUE) %>% { .[!grepl("revdep", .)] } %>% { .[!grepl("Rcheck", .)] } for (desc_file in descriptions) { if (!file.exists(gsub("DESCRIPTION", "LICENSE", desc_file))) { folder <- gsub("DESCRIPTION", "", desc_file) cat("Adding LICENSE to ", folder, "\n", sep = "") fs::file_copy("LICENSE", paste0(folder, "/LICENSE")) fs::file_copy("LICENSE.md", paste0(folder, "/LICENSE.md")) des <- desc(desc_file) des$set("License", "MIT + LICENSE file") des$write() system(paste0( "pushd '", folder, "' && git add DESCRIPTION LICENSE LICENSE.md", " && git commit -m 'update license'", " && git push && popd" )) } } # Also handles bare submodule paths listed in .gitmodules subrepos <- readr::read_lines(".gitmodules") %>% .[grepl("path = ", .)] %>% gsub(".* = ", "", .) for (repo in subrepos) { if (!file.exists(paste0(repo, "/LICENSE"))) { cat("Adding LICENSE to ", repo, "\n", sep = "") fs::file_copy("LICENSE", paste0(repo, "/LICENSE")) fs::file_copy("LICENSE.md", paste0(repo, "/LICENSE.md")) system(paste0( "pushd '", repo, "' && git add LICENSE LICENSE.md", " && git commit -m 'update license'", " && git push && popd" )) } } # Expected: console lines "Adding LICENSE to libraries/dyngen/" for each unlicensed package ``` -------------------------------- ### Common Credentials for CI/CD Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Defines common environment variables for Docker and GitHub PAT, typically used in CI/CD pipelines. ```bash DOCKER_USERNAME=dynverseorg DOCKER_PASSWORD=73...rK GITHUB_PAT=dc...29 ``` -------------------------------- ### Apply Sed Over R Files Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Finds all R files (including Rmd and Rnw) in the current directory and its subdirectories, and applies a sed substitution command to them. ```bash find . -type f -regex ".*.Rm?d?" -print0 | xargs -0 sed -i 's#ALL YOUR BASE#ARE BELONG TO US#g' ``` -------------------------------- ### Generate Package Dependency Plots Source: https://context7.com/dynverse/dynverse/llms.txt Generates and saves PNG plots of package dependencies for each package in the 'dynverse' project. Requires 'igraph', 'ggraph', and 'ggrepel' libraries. ```r pmap(packages, function(package_oi, dir, ...) { pkg_deps <- dependencies %>% mutate(oi = (package == package_oi) | (dependency == package_oi), upstream = (dependency == package_oi)) pkg_nodes <- packages %>% filter(package %in% c(pkg_deps$package, pkg_deps$dependency)) %>% mutate(oi = package == package_oi, oi_connected = package %in% unlist(select(filter(pkg_deps, oi), package, dependency))) sub_graph <- tidygraph::as_tbl_graph( igraph::graph_from_data_frame(d = pkg_deps, directed = TRUE, vertices = pkg_nodes) ) plot <- ggraph(sub_graph, layout = "sugiyama") + geom_edge_diagonal(aes(color = type, alpha = oi, linetype = upstream)) + geom_node_point(aes(alpha = oi_connected)) + ggrepel::geom_label_repel(aes(x = x, y = y, label = name, alpha = oi_connected), nudge_y = 0.1, label.size = 0, fill = "#FFFFFF22", min.segment.length = 0) + scale_edge_color_manual("Dependency type", values = color_type) + theme_graph() + theme(legend.position = "bottom") folder <- paste0(dir, "/man/figures/") if (!fs::dir_exists(folder)) fs::dir_create(folder) ggsave(paste0(folder, "dependencies.png"), plot, width = 12, height = 7) }) ``` -------------------------------- ### Add a New Submodule Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Adds a new submodule to the repository, specifying the branch to track. ```bash git submodule add -b devel git@github.com:dynverse/mfa.git methods/mfa ``` -------------------------------- ### Reset Local Repositories After BFG Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Resets local repositories on each user's machine to match the cleaned remote repository, ensuring consistency after large file removal. ```bash git pull git reset --hard origin/devel git checkout master git reset --hard origin/master git checkout devel ``` -------------------------------- ### Generate Package Dependency Graphs Source: https://context7.com/dynverse/dynverse/llms.txt An Rscript that constructs an ecosystem-wide dependency graph using 'igraph' and visualizes it with 'ggraph'. It saves per-package 'neighbourhood' plots to each package's 'man/figures/dependencies.png'. Requires 'tidyverse', 'ggraph', 'tidygraph', 'igraph', 'desc', and 'fs' packages. ```r #!/usr/bin/Rscript library(tidyverse) library(ggraph) library(tidygraph) requireNamespace("igraph") requireNamespace("desc") requireNamespace("fs") files <- list.files(path = ".", pattern = "DESCRIPTION", recursive = TRUE, full.names = TRUE) packages <- map_df(files, function(file) { descr <- desc::desc(file = file) tibble(package = descr$get("Package"), file = file, dir = gsub("/DESCRIPTION", "", file)) }) %>% filter(!grepl("revdep", dir)) dependencies <- map_df(packages$file, function(file) { descr <- desc::desc(file = file) descr$get_deps() %>% rename(dependency = package) %>% mutate(package = descr$get("Package")) %>% select(package, dependency, type) }) %>% filter(dependency %in% packages$package) # Ecosystem-wide plot color_type <- c("Depends" = "#001f3f", "Imports" = "#0074D9", "Suggests" = "#39CCCC") depgr <- igraph::graph_from_data_frame(d = dependencies, directed = TRUE, vertices = packages) graph <- tidygraph::as_tbl_graph(depgr) ggraph(graph, layout = "sugiyama") + geom_edge_diagonal(aes(color = type)) + geom_node_point() + ggrepel::geom_label_repel(aes(x = x, y = y, label = name), nudge_y = 0.1, label.size = 0, fill = "#FFFFFF22", min.segment.length = 0) + scale_edge_color_manual("Dependency type", values = color_type) + theme_graph() + theme(legend.position = "bottom") ``` -------------------------------- ### Remove a Submodule Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Steps to completely remove a submodule from the repository. ```bash vim .gitmodules # remove relevant section git add .gitmodules vim .git/config # remove relevant section git rm --cached path_to_submodule # no trailing slash rm -rf .git/modules/path_to_submodule # no trailing slash git commit -m "Removed submodule " rm -rf path_to_submodule ``` -------------------------------- ### Re-point Submodule Remotes to Canonical SSH URL Source: https://context7.com/dynverse/dynverse/llms.txt Uses 'git submodule foreach' to iterate over all registered submodules and update their origin remote URL to the canonical SSH pattern. This ensures consistent remote access for submodules. ```bash git submodule foreach \ 'git remote set-url origin \ `pwd | sed "s#.*/\(.*\)#git@github.com:dynverse/\1.git#"`' ``` -------------------------------- ### Update Root Repo and All Submodules Source: https://context7.com/dynverse/dynverse/llms.txt A bash script to pull the latest changes for the main dynverse repository and all its registered submodules. It also specifically updates a nested submodule within 'dynbenchmark/results'. ```bash #!/bin/bash # Run from the dynverse root directory git pull # update root meta-repo git submodule foreach git pull # update every registered submodule pushd dynbenchmark/results git pull # update nested results submodule popd # Expected: each submodule prints its fetch/merge summary or "Already up to date." ``` -------------------------------- ### Update Remote URLs for Submodules Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Updates the remote origin URL for all submodules to the dynverse GitHub organization. Includes a specific override for the monocle submodule. ```bash git submodule foreach 'git remote set-url origin `pwd | sed "s#.*/\(.*\)#git@github.com:dynverse/\1.git#"`' cd methods/monocle; git remote set-url origin git@github.com:dynverse/monocle-release.git; cd ../.. ``` -------------------------------- ### Remove Large Files from Repository (BFG) Source: https://github.com/dynverse/dynverse/blob/master/helper_scripts/common_commands.md Removes large files (blobs) and specified file types from a Git repository using the BFG Repo-Cleaner. This process requires cloning the repository with the --mirror flag and then performing Git garbage collection. ```bash git clone --mirror git@github.com:dynverse/dynbenchmark.git java -jar ~/Downloads/bfg-1.13.0.jar --strip-blobs-bigger-than 100K --protect-blobs-from master,devel --delete-files '*.{png,pdf,svg,rds,RData,csv,txt,tsv,ods,xls,xlsx}' dynbenchmark.git cd dynbenchmark.git git reflog expire --expire=now --all && git gc --prune=now --aggressive git push ``` -------------------------------- ### Remove a Git Submodule Source: https://context7.com/dynverse/dynverse/llms.txt Commands to completely remove a submodule from a Git repository. Ensure to update both .gitmodules and .git/config, and then remove the submodule's cached files and directory. ```bash vim .gitmodules git add .gitmodules vim .git/config git rm --cached path_to_submodule rm -rf .git/modules/path_to_submodule git commit -m "Removed submodule" rm -rf path_to_submodule ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.