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
- THE SINGULARITY | AI That Lies? Faithfulness Concerns in Chain-of-Thought Models - The Hoya - April 23rd, 2025 [April 23rd, 2025]
- HILL: The singularity of the Christian Easter - The North State Journal - April 23rd, 2025 [April 23rd, 2025]
- AI Singularity Shock: Tech Titans Predict Unstoppable Intelligence Explosion Within 12 Months, Sparking Global Fear and Frenzy - Sustainability Times - April 23rd, 2025 [April 23rd, 2025]
- An A.I. Fooled Humans and Passed the Turing Test. But It's a Red Herring for the Singularity. - Popular Mechanics - April 16th, 2025 [April 16th, 2025]
- Singularity AMC gears up to start raising third PE fund - VCCircle - April 16th, 2025 [April 16th, 2025]
- Helldivers 2 Has a Massive Opportunity with the Meridian Singularity - Game Rant - April 16th, 2025 [April 16th, 2025]
- THE SINGULARITY | Elon Musk, DOGE and the Merging of Technology and Politics - The Hoya - April 8th, 2025 [April 8th, 2025]
- The Definition of Singularity - AOL.com - April 8th, 2025 [April 8th, 2025]
- 'God of gaps': singularity and the divine - The Express Tribune - April 8th, 2025 [April 8th, 2025]
- B1A4 sells out 'Singularity' concert tickets ahead of 14th anniversary celebration - CHOSUNBIZ - Chosun Biz - April 8th, 2025 [April 8th, 2025]
- Singularity is a Forest - Style Weekly - March 1st, 2025 [March 1st, 2025]
- Singularity achieved? After shaky start, AI has suddenly become relevant to Oscar predictions - Gold Derby - March 1st, 2025 [March 1st, 2025]
- Humanity May Achieve the Singularity Within the Next 12 Months, Scientists Suggest - Popular Mechanics - February 27th, 2025 [February 27th, 2025]
- Elon Musks big warning on the AI singularity - Washington Examiner - February 27th, 2025 [February 27th, 2025]
- Information Singularity: What Happens When Even AI Experts Can't Keep Up With AI - substack.com - February 27th, 2025 [February 27th, 2025]
- Elon Musk Claims Were on the Event Horizon of the Singularity Are We? - substack.com - February 27th, 2025 [February 27th, 2025]
- How Real Is The Possibility Of AI Going Rogue? Tech Singularity And Elon Musks Warning Explained - News18 - February 25th, 2025 [February 25th, 2025]
- Liberty save us, Helldivers 2 just lost a planet to the deadly black hole we created last year after spaghettifying Meridia, and the singularity is... - February 14th, 2025 [February 14th, 2025]
- Boruto: The Singularity of Fate, Explained - CBR - February 14th, 2025 [February 14th, 2025]
- Top Dubai-based production company Singularity joins the m25 representation network - Campaign Brief Asia - February 14th, 2025 [February 14th, 2025]
- Singularity Finance Announces Collaboration with Particle Network - Brave New Coin Insights - January 27th, 2025 [January 27th, 2025]
- Singularity Finance Teams Up With Particle Network To Streamline Tokenized AI Transactions - The Crypto Basic - January 27th, 2025 [January 27th, 2025]
- Davos 2025: Africa at the crossroads of circularity and singularity - Punch Newspapers - January 27th, 2025 [January 27th, 2025]
- Singularity Finance Partners with Zoth for ZLTN Prime Tokenized Asset - Crypto News Flash - December 27th, 2024 [December 27th, 2024]
- Is 2025 the Year AI Agents Take Over? Industry Bets Billions on AIs Killer App - Singularity Hub - December 27th, 2024 [December 27th, 2024]
- Call of Duty: World at War and Singularity reportedly coming to Game Pass - Video Games Chronicle - December 27th, 2024 [December 27th, 2024]
- AI That Can Design Life's Machinery From Scratch Had a Big Year. Here's What Happens Next. - Singularity Hub - December 27th, 2024 [December 27th, 2024]
- Call of Duty: World at War, Singularity to Reportedly Join Game Pass in 2025 - Gadgets 360 - December 27th, 2024 [December 27th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through December 21) - Singularity Hub - December 27th, 2024 [December 27th, 2024]
- Singularity Advocate Series #1: AI with a Mind of Its Own, On Trial for its Life - JD Supra - December 16th, 2024 [December 16th, 2024]
- ISC East Recap: The Unification Singularity - SecurityInfoWatch - December 16th, 2024 [December 16th, 2024]
- The Singularity: The Future of Man and Machine - Observer Research Foundation - December 14th, 2024 [December 14th, 2024]
- The Secret to Predicting How Your Brain Will Age May Be in Your Blood - Singularity Hub - December 14th, 2024 [December 14th, 2024]
- Thousands of Undiscovered Genes May Be Hidden in DNA Dark Matter - Singularity Hub - December 14th, 2024 [December 14th, 2024]
- Darryl Vidal's Sci-Fi Thriller MindCraft: The Educational Singularity Delivers an Electrifying Vision of the Future - Benzinga - December 10th, 2024 [December 10th, 2024]
- Theoretical physicist wants to know whats at a singularity - Cosmos - December 10th, 2024 [December 10th, 2024]
- Singularity Finance: Making AI and RWAs Easy to Access - Crypto Times - December 10th, 2024 [December 10th, 2024]
- Humanity May Reach Singularity Within Just 6 Years, Trend Shows - Yahoo! Voices - December 8th, 2024 [December 8th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through December 7) - Singularity Hub - December 8th, 2024 [December 8th, 2024]
- The Singularity Is Nearsighted, A Book Review - Forbes - December 8th, 2024 [December 8th, 2024]
- Most Supposedly Open AI Systems Are Actually Closedand Thats a Problem - Singularity Hub - December 2nd, 2024 [December 2nd, 2024]
- Humanity May Reach Singularity Within Just 6 Years, Trend Shows - MSN - December 2nd, 2024 [December 2nd, 2024]
- Humanity May Reach Singularity Within Just 6 Years, Trend Shows - Popular Mechanics - November 30th, 2024 [November 30th, 2024]
- Singularity alert: AIs are already designing their own chips - New Atlas - November 30th, 2024 [November 30th, 2024]
- OpenAIs GPT-4o Makes AI Clones of Real People With Surprising Ease - Singularity Hub - November 30th, 2024 [November 30th, 2024]
- A 4.45-Billion-Year-Old Crystal From Mars Reveals the Planet Had Water From the Beginning - Singularity Hub - November 30th, 2024 [November 30th, 2024]
- This Weeks Awesome Tech Stories From Around the Web (Through November 23) - Singularity Hub - November 26th, 2024 [November 26th, 2024]
- 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]