The sleight-of-hand trick that can simplify scientific computing – Nature.com
Research software is like the tower-building game Jenga tools atop tools atop tools. When developers tweak their individual pieces, this can change the function of the software that depends on them, potentially altering results or causing the software to fail.
Version 3.6.0 of the R programming language, for instance, introduced a replacement algorithm for generating random numbers. This and the older algorithm both work, but not in the same way. If you ran the same code with an older version of R and a newer version of R and it was using any function that needed to generate a random number, you would end up getting different results, says Tiffany Timbers, a data scientist at the University of British Columbia in Vancouver, Canada.
Among other things, that kind of variability can complicate collaboration (see Environmental testing). In 2020, Mine etinkaya-Rundel was working with another author on a statistics textbook, using R and a formatting language called R Markdown to calculate numbers, create figures and format the final document. We wanted to make sure that we were using the same versions, says etinkaya-Rundel, a statistician at Duke University in Durham, North Carolina, and also that when we re-render the book, were rendering it with a given version of the packages. If not, the two authors could have generated slightly different manuscripts.
An example of how variable computing environments can hinder collaboration.
Suppose you have the latest versions of R and Python installed, but your collaborator has been slower to upgrade. They want to share a Python script with you, and you have an R program you want them to use. Will the code work in each others hands?
Between Python 2 and Python 3, the print command that outputs text to the screen changed. The directive print hello, world! is valid in Python 2, but Python 3 requires parentheses print (hello, world!). Similarly, before R 4.0, the function that creates spreadsheet-like data tables treated text as discrete factors by default, whereas later versions do not.
To highlight these differences, we created scripts and environments for Python 2.7, Python 3.11, R 3.6 and R 4.2 (see go.nature.com/4tirjm7). Following the instructions (see go.nature.com/4tnd5ke), install conda. Then, open a terminal window, run the set-up script and execute run.sh. You should see the code working correctly in one environment but not in the other. For instance, although the R script behaves as intended in R 4.2 it changes the gender of a study subject it does something unexpected (and issues a warning) in R 3.6.
To address that challenge, they turned to the R package renv, one of a small group of tools that help developers and researchers to manage their computational environments; other options include venv and virtualenv for Python, and conda, a language-agnostic tool. Most are command-line utilities, although renv is tightly integrated with the RStudio Desktop graphical programming environment. All can help researchers to ensure that their code is reproducible, reusable, documented and shareable.
C. Titus Brown, a bioinformatician at the University of California, Davis, has 187 conda environments on his laptop. Most are one-offs, used to test new tools or to illustrate a point during lectures. His day-to-day work mostly takes place in a development environment that includes a specific version of Python and other programming tools.
Some tasks, however, require a change of computational scenery. For instance, Brown writes blog posts in Markdown, which he renders into HTML, the standard markup language for web pages. But the code that performs that step doesnt work well with newer versions of a crucial software library, and older versions conflict with his development tools. To isolate the problem, Brown created a separate environment. I just fixed the version to something really old that still works, and I run [the rendering software] there, he says.
NatureTech
A conda environment is a computational sleight-of-hand, says Johannes Kster, a computer scientist at the University of Duisburg-Essen in Germany, who founded a bioinformatics-focused software repository called Bioconda. Basically, its just modifying your system path the place where your system searches for executable [applications]. You might have multiple versions of a tool installed, but when conda activates a particular environment, your computer can only see the one you want.
Computational environments offer several benefits, says Timbers. One is reproducibility the ability to analyse the same data with the same software on the same computing infrastructure to get the same results.
It can be very frustrating, tracing down the differences between outputs across different computers, says Ben Marwick, an archaeologist at the University of Washington in Seattle. Some research projects take years to complete, he notes. And although Marwick prefers the newest libraries, his colleagues dont always upgrade at the same pace. Renv ensures that he and his collaborators always run their project codes in the same way. The resulting environment-description file can be version-controlled and shared on GitHub. Collaborators can recreate the environment using the command renv::restore()Conda is a command-line tool that both creates environments and installs software into them. To create a new environment called my_env pinned to a specific version of Python, for instance, use conda create --name my_env python=3.9
Both R and conda allow users to install their own tools rather than having to ask system administrators to do it for them. You dont need root privileges, says Rob Patro, a computational biologist at the University of Maryland in College Park. This is a useful feature when working on shared computing resources.
Environment managers also make software installation easier. Scientific software is often released as source code, which might need to be compiled, configured and installed in a specific location. It might have a network of dependencies, written in multiple programming languages, that must be installed in a particular order. Sometimes, says bioinformatician Fredrik Boulund at the Karolinska Institute in Stockholm, the process can be beyond users skills. That completely changed when solutions like conda entered the scene, he says. Installing a complex set of dependencies is simply reduced to asking conda to create an environment according to an environment specification file.
Cut the tyranny of copy-and-paste with these coding tools
For the Galaxy project an open-source framework for reproducible data analysis those features were a key reason for choosing conda as the projects software installation manager. Bioinformatician Bjrn Grning, who runs the European Galaxy server at the University of Freiburg in Germany, says that the Galaxy community started searching for a cohesive tool-installation strategy in around 2015 because its existing, manual approach was unsustainable. Conda ticked all our requirement boxes, Grning says. It doesnt need root privileges; it is programming-language agnostic; and it uses human-readable package recipes that are easy to understand and maintain. Today, there are more than 9,000 bioinformatics tools available to Galaxy users through the Bioconda channel.
Perhaps the biggest benefit to environments, however, is isolation: environments enable researchers to explore new or updated tools while knowing that their code will still run.
Elana Fertig, a statistician at Johns Hopkins University in Baltimore, Maryland, describes herself as lax when it comes to environments: For me, everything goes in one environment. But larger environments are harder to use, because the environment manager has to resolve a larger network of dependencies to install new tools. (Conda is notorious for poor performance with large environments, but a drop-in resolver called mamba accelerates the process.) Instead, Fertig suggests that her students use one environment per project.
Indeed, most researchers contacted for this article recommend creating environments to accommodate specific workflows or projects and to do so early on. Start your project with a package-management solution in mind, says Joshua Shapiro, senior data scientist at the Childhood Cancer Data Lab for Alexs Lemonade Stand Foundation, based in Wynnewood, Pennsylvania. It has the potential to save a lot of headaches down the line.
Challenge to scientists: does your ten-year-old code still run?
Tommy Tang, director of computational biology at Immunitas Therapeutics, a biotechnology company in Waltham, Massachusetts, uses dedicated environments for different computational tasks processing data from RNA sequencing or working in Google Cloud, for instance.
Users of the Snakemake and Nextflow computational workflow managers can even direct those tools to execute each step in a separate conda environment, says Kster, who leads Snakemake development. Make them as fine-grained and as single-purpose as possible, he advises. Besides being easier to maintain, he explains, small environments are also more transparent. People who want to understand what the analysis actually did immediately see what software stack was used for which step.
Still, environments cant do everything. Tools written in languages such as C, Perl and Fortran can be hard to encapsulate into environments, and dependency differences can make environments difficult to port across operating systems. In that case, users can try software containers, such as those from Docker and Singularity.
Containers, which essentially package a tool with its underlying operating system, are larger and more complicated than environments, but are more portable. They are also easier to share, because although an environment can hold thousands of files, a container has only one. On high-performance systems in which jobs can be run in parallel across hundreds of computing cores, transferring many small files can affect performance.
Computational environments, says Timbers, are the forgotten child of reproducibility. Journals increasingly ask for code and data alongside manuscripts, but full reproducibility requires knowing the environment in which they were run. Its the elephant in the room, she says.
View post:
The sleight-of-hand trick that can simplify scientific computing - Nature.com
- Album Review: WO FAT The Singularity - Metal Injection - November 19th, 2024 [November 19th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through November 16) - Singularity Hub - November 19th, 2024 [November 19th, 2024]
- Could We Ever Decipher an Alien Language? Uncovering How AI Communicates May Be Key - Singularity Hub - November 19th, 2024 [November 19th, 2024]
- THE SINGULARITY | Georgetown Doesnt Need Engineering - Georgetown University The Hoya - November 17th, 2024 [November 17th, 2024]
- Simulation and kinematic analysis of a 3-DOF marine antenna pedestal focusing on singularity avoidance and its effects on angular velocity and angular... - November 17th, 2024 [November 17th, 2024]
- Book Review The many and the singularity - Morning Star Online - November 16th, 2024 [November 16th, 2024]
- MIT's New Robot Dog Learned to Walk and Climb in a Simulation Whipped Up by Generative AI - Singularity Hub - November 16th, 2024 [November 16th, 2024]
- Sweet CRISPR Tomatoes May Be Coming to a Supermarket Near You - Singularity Hub - November 16th, 2024 [November 16th, 2024]
- Outlier Ventures Partners with Singularity Finance on the RWA Base Camp Accelerator Program - CryptoGlobe - November 12th, 2024 [November 12th, 2024]
- AI Singularity might take place under Trump presidency, AI experts are worried - Firstpost - November 12th, 2024 [November 12th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through November 9) - Singularity Hub - November 12th, 2024 [November 12th, 2024]
- SentinelOne to showcase AI-powered Singularity Platform at Gitex Global this year - Gulf News - October 14th, 2024 [October 14th, 2024]
- Our Mutual Friend: A Review of The Singularity Is Nearer: When We Merge with AI by Ray Kurzweil - Newcity Lit - October 14th, 2024 [October 14th, 2024]
- Youll Soon Be Able to Book a Room at the Worlds First 3D-Printed Hotel - Singularity Hub - October 14th, 2024 [October 14th, 2024]
- THE SINGULARITY | What Artificial Intelligence Means for Academia - Georgetown University The Hoya - October 9th, 2024 [October 9th, 2024]
- Inside Singularity's second gathering of business heads in India | Mint - Mint - October 9th, 2024 [October 9th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through October 5) - Singularity Hub - October 9th, 2024 [October 9th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through September 21) - Singularity Hub - September 22nd, 2024 [September 22nd, 2024]
- Valorant Singularity 2.0 is Repeating the Worst Fortnite Blunder: Riot is Running Out of Ideas to Cash in on Old Skins - imdb - September 22nd, 2024 [September 22nd, 2024]
- SentinelOne Takes Top Honors at 2024 SC Media Awards as AI-Powered Singularity Platform Wins Best Enterprise Security Solution and Best Endpoint... - September 22nd, 2024 [September 22nd, 2024]
- Elderly Monkeys Aged More Slowly When Given a Cheap Diabetes Drug Used by Millions - Singularity Hub - September 22nd, 2024 [September 22nd, 2024]
- Christos Yannaras and the Hellenic Diaspora: Rediscovering Singularity - The National Herald - September 14th, 2024 [September 14th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through September 14) - Singularity Hub - September 14th, 2024 [September 14th, 2024]
- Jackalope Theatre Companys The Singularity Play - Choose Chicago - September 14th, 2024 [September 14th, 2024]
- SentinelOne Achieves FedRAMP High Authorization for Singularity Platform and Singularity Data Lake - StockTitan - September 14th, 2024 [September 14th, 2024]
- A New Gene Therapy Reprograms Cancer Cells to Fight Themselves - Singularity Hub - September 14th, 2024 [September 14th, 2024]
- The singularity of literary production: Nirmal Verma and Jorge Luis Borges in London, 1976 - Scroll.in - September 14th, 2024 [September 14th, 2024]
- Robots Are Coming to the KitchenWhat That Could Mean for Society and Culture - Singularity Hub - September 3rd, 2024 [September 3rd, 2024]
- 463. The Road to Singularity: Ben Goertzel on AGI and The Fate of Humanity - Skeptic Magazine - September 3rd, 2024 [September 3rd, 2024]
- We Think Singularity Future Technology (NASDAQ:SGLY) Can Afford To Drive Business Growth - Yahoo Finance - September 3rd, 2024 [September 3rd, 2024]
- Backyard Naturalist: The woods and The Singularity - Kennebec Journal and Morning Sentinel - September 3rd, 2024 [September 3rd, 2024]
- The US Is Adding Grid-Scale Batteries at 10 Times the Pace of Natural Gas This Year - Singularity Hub - September 3rd, 2024 [September 3rd, 2024]
- The singularity: How AI could become the final boss whale of crypto - Cointelegraph - August 27th, 2024 [August 27th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through August 24) - Singularity Hub - August 27th, 2024 [August 27th, 2024]
- The Singularity Is Coming Soon. Heres What It May Mean. - Forbes - August 27th, 2024 [August 27th, 2024]
- What Is Model Collapse? An Expert Explains the Rumors About an Impending AI Doom - Singularity Hub - August 27th, 2024 [August 27th, 2024]
- The singularity: How AI could become the final boss whale of crypto - StartupNews.fyi - August 27th, 2024 [August 27th, 2024]
- This AI Learns Continuously From New ExperiencesWithout Forgetting Its Past - Singularity Hub - August 27th, 2024 [August 27th, 2024]
- Short Interest in Singularity Future Technology Ltd. (NASDAQ:SGLY) Drops By 14.8% - Defense World - July 28th, 2024 [July 28th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through July 27) - Singularity Hub - July 28th, 2024 [July 28th, 2024]
- What Is the Singularity? And Should You Be Worried? - Electronics | HowStuffWorks - July 28th, 2024 [July 28th, 2024]
- The Singularity by 2045, Plus 6 Other Ray Kurzweil Predictions - Electronics | HowStuffWorks - July 28th, 2024 [July 28th, 2024]
- AI-Powered Weather and Climate Models Are Set to Change Forecasting - Singularity Hub - July 28th, 2024 [July 28th, 2024]
- This Is What Could Happen if AI Content Is Allowed to Take Over the Internet - Singularity Hub - July 28th, 2024 [July 28th, 2024]
- Scientists Say They Extended Mices Lifespans 25% With an Antibody Drug - Singularity Hub - July 28th, 2024 [July 28th, 2024]
- Ray Kurzweil Still Says He Will Merge With A.I. - The New York Times - July 6th, 2024 [July 6th, 2024]
- Daybreak acquires Singularity 6 - GamesIndustry.biz - July 6th, 2024 [July 6th, 2024]
- Daybreak bought Palia studio Singularity 6 and aims to bring the game to launch - Massively Overpowered - July 6th, 2024 [July 6th, 2024]
- Palia developer Singularity 6 is now part of the Daybreak Game Company - PC Gamer - July 6th, 2024 [July 6th, 2024]
- Daybreak Acquires Palia Developer Singularity 6 - The Outerhaven - July 6th, 2024 [July 6th, 2024]
- Chinese company achieves breakthrough in race to fusion here's why it's a major step toward unlimited affordable power - The Cool Down - July 6th, 2024 [July 6th, 2024]
- Ray Kurzweil Predicts the AI Future by 2045 - The Dales Report - July 6th, 2024 [July 6th, 2024]
- Education in the spotlight at Singularity South Africa Summit 2024 - Bizcommunity.com - July 6th, 2024 [July 6th, 2024]
- Daybreak Has Acquired Palia Studio Singularity 6 - PlayStation Universe - July 6th, 2024 [July 6th, 2024]
- The Singularity Heist: When AIs Crave Crypto | by Anthony Williams | Jun, 2024 - DataDrivenInvestor - June 20th, 2024 [June 20th, 2024]
- What 70 Years of AI on Film Can Tell Us About the Human Relationship With Artificial Intelligence - Singularity Hub - June 20th, 2024 [June 20th, 2024]
- SNL: Anthony Michael Hall on RDJ Bond, Sketches, "Singularity" Update - Bleeding Cool News - June 16th, 2024 [June 16th, 2024]
- What "naked" singularities are revealing about quantum space-time - New Scientist - June 16th, 2024 [June 16th, 2024]
- Review: "The Singularity Play" by Jackalope Theatre Company - Chicago Tribune - June 16th, 2024 [June 16th, 2024]
- This Week's Awesome Tech Stories From Around the Web (Through June 15) - Singularity Hub - June 16th, 2024 [June 16th, 2024]
- The AI Singularity Is Nothing to Fear - hackernoon.com - June 16th, 2024 [June 16th, 2024]
- AI Unearths Nearly a Million Potential Antibiotics to Take Out Superbugs - Singularity Hub - June 16th, 2024 [June 16th, 2024]
- The Singularity Play tackles AI - Chicago Reader - May 31st, 2024 [May 31st, 2024]
- Black hole singularities defy physics. New research could finally do away with them. - Space.com - May 31st, 2024 [May 31st, 2024]
- This Week's Awesome Tech Stories From Around the Web (Through May 25) - Singularity Hub - May 31st, 2024 [May 31st, 2024]
- This Device Zaps the Spinal Cord to Give Paralyzed People Use of Their Hands Again - Singularity Hub - May 31st, 2024 [May 31st, 2024]
- Converging Towards The Radio Singularity - RadioInsight - RadioInsight - May 3rd, 2024 [May 3rd, 2024]
- This Week's Awesome Tech Stories From Around the Web (Through April 27) - Singularity Hub - May 3rd, 2024 [May 3rd, 2024]
- I never would have dreamed that I would hear this song performed by two of the guitar gods who inspired it: Joe ... - Guitar World - May 3rd, 2024 [May 3rd, 2024]
- Scientists Find a Surprising Way to Transform A and B Blood Types Into Universal Blood - Singularity Hub - May 3rd, 2024 [May 3rd, 2024]
- This Week's Awesome Tech Stories From Around the Web (Through March 16) - Singularity Hub - March 18th, 2024 [March 18th, 2024]
- Breakpoint: The promises and perils of artificial intelligence - Chattanooga Times Free Press - March 18th, 2024 [March 18th, 2024]
- Palia reaches over 3m players in six months thanks to "invaluable" Switch partnership - GamesIndustry.biz - March 18th, 2024 [March 18th, 2024]
- This Week's Awesome Tech Stories From Around the Web (Through February 3) - Singularity Hub - February 8th, 2024 [February 8th, 2024]
- EIA Says 40 Percent of US Electricity Is Now Emission-Free for the First Time - Singularity Hub - January 10th, 2024 [January 10th, 2024]
- The Crossroads of Humanity: Embracing the Singularity | by Michiel Meire | Jan, 2024 - Medium - January 10th, 2024 [January 10th, 2024]
- Debating the Claim of Consciousness by Haley AI and the Ethical Implications of AI - Medriva - January 10th, 2024 [January 10th, 2024]
- [Master Duel] November 9th Update - YGOrganization - November 9th, 2023 [November 9th, 2023]
- Palia Update Adds New Customization Options, Starstones, and More - GameRant - November 9th, 2023 [November 9th, 2023]
- Robby Krieger And The Soul Savages Announce Debut Album - Dig! - November 9th, 2023 [November 9th, 2023]