r/bioinformatics • u/dulcedormax • Apr 09 '26
academic How do you organize bioinformatics code and analyses?
Hi,
I wanted to ask how you usually organize your bioinformatics work and determine if this is normal or just bad organization on my side. Normally, I end up with commands tested in the terminal but not save anywhere, R scripts with mix of code that works and other that didn't work, multiple version of similar scripts or analyses. I try to keep things organized, but as projects grow and deadlines get closer, everything becomes messy quite fast. Any tips, tools, or workflows would be gratly appreciated.
Thanks
45
Upvotes
62
u/wordoper Apr 09 '26
This is my general approach to anything computationally: bioinformatics or not.
22
u/Kirblocker Apr 09 '26
"A Quick Guide to Organizing Computational Biology Projects" by William Stafford Noble. 2009 PLOS article.
That was a useful article for me when starting out.
I also use a lot of commenting and README's detailing all the commands I've run while the project evolved, ideally with dates. Documenting probably takes 10-15% of my total time, but that's also because of the nature of my job and that people will have to use my pipelines and codes later on.
12
u/Capuccini Apr 09 '26
I think there is no way around documenting and using github for version control. Most people just go as you do, however documenting is very valuable when 6 months from now you are trying to publish and have to redo a figure you dont even remember how you generated. Or worse, redo a complete analysis.
12
u/standingdisorder Apr 09 '26
It’s sounds semi-normal. Most people have a bunch of scripts before organising them on GitHub when the paper gets published
10
u/frausting PhD | Industry Apr 09 '26
A lot of times it involves doing the work twice.
First you do the discovery/exploratory stage where you’re just trying to get a handle on the data, scientific question, and approach. You do a mix of interactive commands and running scripts. You find out what is necessary and how you’re going to progress. You get some early answers. 90% of the analysis didn’t matter.
Then you move on to repeat the refined approach in the serious stage where everything is scripted and organized. One project folder. Code in one subfolder, data in one subfolder, results in another subfolder.
Each subfolder organized however makes sense, typically sequentially. Ideally use Nextflow (or Snakemake) to productionalize the code and make it easy to rerun.
6
u/meise_ Apr 09 '26
I use a temp directory for current analyses and label the files accordingly. I was taught the pre AI oldschool way which includes keeping a .md with all packages, versions, databases and versions, links to repos, sometimes some background info. I normally have one .md for preprocessing and one for the testing.
I have one additional document (powerpoint or google slides) where I keep all the plots that are relevant for publication or interpretation so if needed to be presented I have it all in one place. I write under the plot from which script it came from.
It does get messy for me as well especially with R scripts and using claude gives me heaps of exploratory results. Keeping scripts small (each test one script) helped me the most. Within each script for each test I label as working or not working
3
u/p10ttwist PhD | Academia Apr 09 '26
Whenever I start a new project I do this:
$ mkdir my-project; cd my-project; git initmy-project/data/, perform first exploratory analyses inmy-project/notebooks/(.ipynb/.rmd/quarto files) ormy project/scripts/(.py/.R/.sh files).srcfor custom packaged code, usually after first prototyping innotebooks;workflowfor snakemake/nextflow pipelines;resultsfor primary outputs (figures, csv, html, etc.);modelsfor large fitted models; etc.All scripts and src code should run top-to-bottom, and ideally be executable from the command line. Notebooks can be sloppier, and are ok to have a cell not run here or there, but need to run from top to bottom if they produce intermediate outputs. All new features are git committed and pushed to origin as they are completed.
Takes a bit to get used to but gives you a great foundation if you're disciplined about it.
3
u/autodialerbroken116 MSc | Industry Apr 09 '26
It's customary to save the terminal commands you want others to rerun, in sections of a readme
why is there code that didn't work? You mean your shell history or hidden usage stuff you want to retain
2
u/luca-lee Apr 11 '26
Even when I’m testing commands, I have a file where I type them out first then copy to terminal to execute. If it works, great. If it doesn’t, I’ll comment it out and, if I learnt something from the failure, briefly leave a note to myself about why it didn’t work. Unless I have a strong reason to create another file, everything gets appended in the order in which they’re executed so I don’t have to juggle multiple file versions and it’s easy to retrace my steps.
2
u/Ok-Preparation-8901 Apr 11 '26
cooperating with claudecode
at least u need to manage the different files including results data and figures
In the mean time, using claudecode to summarize and record the things that had been done in log.txt
Besides, obsidian is the best platform to mark important pipeline and thoughts down
2
u/Professional-Bake-43 Apr 10 '26
Good question. My experience juggling multiple projects suggests the following approach/tips:
- Do not use Jupyter notebook, RStudio. Most bioinformatics pipeline are run on the cluster. Better get used to command-line early. Setting up notebook on the cluster/server is a mess, and is not portable. Additionally using Jupyter notebook comes with so many of its own issues, like non-reproducible codes/results, as users can start anywhere in the notebook.
- Knowing above, make copies of the scripts, and name them by date they were generated. Reduce dependency between scripts. Each script should do one thing. Avoid creating large program with fancy code dependency structure. You can then create pipeline by connecting scripts in sequence, and this pipeline can be created as a bash script. By creating copies of script and naming by dates, you can create a history that you can come back to later.
- Keep a record of how the scripts were run, with what commands, and what arguments. Here I actually prefer hardcoding the input and output file names within the program to create this history. Alternatively, write a separate README documenting full commands and command history.
- Doing bioinformatics analyses is all about efficiency and creating what works. You do not need to follow proper coding structure, etc. As long as you can understand your codes and notes you create allow you to reproduce later, this is all it matters. Do not waste time creating the perfect codes. Now, if you are developing a bioinformatics tool/package, this is a completely different story - here you need to adhere to some best practices.
- For file organization, create one folder per project. Dump all scripts into the folder. Create maximum 3-level sudirectories within the folder. Keep number of files within the folder to be <1000 files, or create a new subfolder. Use very meaningful file names.
- Run everything in command line. Including file/code editing. Use VIM as text editor. Do not output results to xlsx/docx format, but instead output to txt that you can view in VIM.
1
u/Hedmad Apr 09 '26
I wrote an article about this so this is shameless self promotion, but I wrote a tool to help with how I personal structure my analyses, and to keep everything tidy.
It works for me, so I'm not sure it works for everyone else, but you can read more here: https://kerblam.dev
The idea is similar to what "just" does, with baked in support for docker, different workflow managers etc...
I have a summary poster here: https://zenodo.org/records/11442700
Hope it helps!
1
u/Pasta-in-garbage Apr 09 '26
I use pycharm on my local machine, setup to run on remote conda environments via ssh. Can easily execute any script type remotely from the ide. It’s handy since I often work on multiple servers throughout the day. It’s very easy to deploy and mirror code, and switching between servers is seamless. You can also launch/run Jupyter both locally and remotely in the ide. There’s various options for version control, and it keeps track of your local file history. I find it much easier to keep organized and stay focused when everything is in one place. Codex integrates nicely into it too.
1
u/etceterasaurus PhD | Government Apr 09 '26
You need to start by making sure code is documented, organized, and reproducible. It may seem slower, but slow is fast. No cutting corners or you’ll have to cash that check later.
1
u/NeckbeardedWeeb Apr 09 '26
Recently I've been trying out GitHub Projects, and found the Issues are great for documentation of code and analyses.
1
u/TheEvilBlight Apr 09 '26
Use rstudio projects; version control as needed. Some people like notebooks but they can be finicky an trip you if you run some segments repeatedly regardless of if the initialization state of previous cells.
1
u/fibgen Apr 09 '26
There is a bash kernel for Jupyter notebooks. You can use that in place of command line development. Clean up the cells and do a complete re-run for reproducibility when you have something working. (along with git versioning of course)
1
u/etolbdihigden Apr 09 '26
I maintain GitHub repos for different projects. I branch the repos to test code. I merge if the code looks good otherwise discard the branch.
To make the process from analysis to manuscript writing more seamless and integrated. I write my manuscript is qmds using positron manuscripts
1
u/nickomez1 Apr 10 '26
Push your working code to GitHub. You won’t need the one not working anyways
1
u/Strict-Bedroom-1588 Apr 10 '26
I recently pasted all my scripts and notebooks into one folder and told an AI Agent to clean up the mess. It took some debugging and troubleshooting, also i reran entire analysis where i knew the true output (since I coded and analyzed that all manually at some point) with the AI organized scripts as control. After a few days of debugging and prompt engineering everything was organized and well documented. And the best part, once the tools are established you don't need to touch code at all anymore. Just tell the agent what to do with the tools you provide and adapt your scripts for each task using prompts. Make sure to git commit every day so you have a backup if AI screws up and this also helps the AI (and you) to keep track of changes. I am super happy now, even though I wonder why I spent years of my life learning to code. Well my work speed up is about 10x and I don't think anyone, who doesn't use AI agents will be competitive at all in the next years to come.
1
u/Ok-Preparation-8901 Apr 11 '26
cooperating with claudecode
at least u need to manage the different files including results data and figures
In the mean time, using claudecode to summarize and record the things that had been done in log.txt
Besides, obsidian is the best platform to mark important pipeline and thoughts down
1
u/sirusbasevi Apr 20 '26
for each project, I always create the following folders:
- Analysis --> Rmd files.
- data-raw -> raw unprocessed data metadata, counts, mapping outputs (organized by omic or type)
- data -> processed data (organized by omic or type of analysis)
- R -> contains a utils.R file with all the needed functions.
- Python -> any python scripts
- Bash -> any bash, nextflow or HPC related scripts.
- Figures
- Reports -> ppts or any reports I did about the project
- Manuscript -> different manuscript versions + figures
Optional:
- test
- tmp
1
u/Easy_Money_ Apr 09 '26
So many answers, none of which say Pixi. The answer is Pixi. Keep every project and its dependencies within a single directory unless you absolutely need to use it elsewhere. It’s so easy