Skip to content

Instantly share code, notes, and snippets.

@grst
Created October 26, 2020 13:32
Show Gist options
  • Save grst/9d8203cd67faa16f6885da1437b9d7d6 to your computer and use it in GitHub Desktop.
Save grst/9d8203cd67faa16f6885da1437b9d7d6 to your computer and use it in GitHub Desktop.
draft of nextflow/notebook integration

jupyter nextflow plugin

It would be great to have a tighter integration with jupyter notebooks/Rmd notebooks.

See also Reportsrender v2 / Executable book project Reportsrender v2.

Parametrization with papermill/rmarkdown works, but is quite a bit of overhead. It should be possible to execute the notebooks from outside the pipeline (for development) and from within the pipeline using the results from the previous processes (in production)

Maybe a Python/R package could help abstracting the file loading.

This is how it should look like:

import nextflowreporter as nfx

input_file = nfx.channel["input_file"]
param = nfx.channel["value_channel"]
input_file2 = nfx.get_input("input_file2", "/path/used/outside/nextflow.fasta")
# takes care of writing to a temporary file / default directory
# when outside nextflow. 
with nfx.output_file("figure.png") as f:
    fig.savefig(f)

In Nextflow:

// can this be represented in a more compact way using DSL2 modules? 

process foo {
	input:
        input_file from Channel.fromPath("allInputFiles*")
        input_file2 from inputfiles2
        //or anything supported by jupytext
        notebook from Channel.fromPath("notebook.ipynb")
        
    output:
    	"figure.png" into output
        // this will be collected and turned into a website using sphinx. 
        "report.md" into reportxxx
        
    """
    # need to perform some groovy magic to automatically
    # get the notebook name and all input names. 
    nfxreport 
    """   
    
    
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment