Skip to content

Latest commit

 

History

History
274 lines (200 loc) · 5.53 KB

TUTORIAL_julia.md

File metadata and controls

274 lines (200 loc) · 5.53 KB

PhysiCell Data Loader Tutorial: pcdl and the Julia language

Julia is a scientific computing language.

✨ Run pcdl within Julia

We are using the PyCall.js library to run pcdl within Julia.

Make sure that the python3 environment is activated, which has pcdl installed.

Fire up a Juila shell.

julia

Pakage installation.

using Pkg
Pkdg.add("PyCall")

Run pcdl.

using PyCall

pcdl = pyimport("pcdl")  # import the pcdl module.
mcdsts = pcdl.TimeSeries("path/to/PhysiCell/output/")  # load an mcds time series.

?mcdsts.get_cell_df()  # retrieve a function's docstring.
df = mcdsts.get_cell_df()  # retrieve the cell dataframe.

✨ Handle csv files

Save pcdl data structures as csv files from the command line

cd path/to/PhysiCell
pcdl_get_conc_df output
pcdl_get_cell_df output

Load a csv file into jula data structures

We are using the DataFrames.js library, to load the csv files.

Package installation.

using Pkg
Pkdg.add("CSV")
Pkdg.add("DataFrames")

Load csv into a dataframe.

using CSV
using DataFrames
df_cell = CSV.File("output/timeseries_cell.csv") |> DataFrame
df_conc = CSV.File("output/timeseries_cell.csv") |> DataFrame

✨ Handle json files

Save pcdl data structures as json files from the command line

cd path/to/PhysiCell
pcdl_get_conc_attribute output 2
pcdl_get_cell_attribute output 2

Load json files into a julia data structures

We are using the JSON3.js library, to load the json files.

Package installation.

using Pkg
Pkg.add("JSON3")

Load json.

using JSON3
json_string = read("output/timeseries_conc_attribute_minmax.json", String)
j_conc = JSON3.read(json_string)
json_string = read("output/timeseries_cell_attribute_minmax.json", String)
j_cell = JSON3.read(json_string)

✨ Handle gml graph files

Save pcdl data structures as gml files from the command line

cd path/to/PhysiCell
pcdl_make_graph_gml output/output00000024.xml neighbor --node_attribute cell_type dead oxygen pressure

Load gml files into a julia data structures

⚠ bue 2024-09-04: this is currently not working, since, for now, GraphIO cannot handle the graph, node, or edge metadata in the file ( JuliaGraphs/GraphIO.jl#46 ).

We will use the GraphIO.js library, to load gml files.

Package installation.

using Pkg
Pkg.add("GraphIO")
Pkg.add("Graphs")
Pkg.add("ParserCombinator")

Load gml.

using GraphIO
using Graphs
using ParserCombinator
graph = loadgraph("output/output00000024_neighbor.gml", GraphIO.GML.GMLFormat())

Please study the Graphs documentation to learn how to analyze graph data.

✨ Handle h5ad single cell data files

Save pcdl data structures as h5ad files from the command line

cd path/to/PhysiCell
pcdl_get_anndata output/

Load h5ad files into a julia data structures

We will use scverse's Muon.jl library, to load h5ad files.

Package installation.

using Pkg
Pkg.add("Muon")

Load h5ad.

using Muon
adata = readh5ad("output/timeseries_cell_maxabs.h5ad")

Please study the Muon and AnnData documentation to learn how to analyze this data.

✨ Handle ome.tiff, tiff, png, and jpeg file format

Save pcdl data structures as jpeg, png, tiff, and ome.tiff files from the command line

pcdl_plot_contour output/output00000021.xml oxygen --ext tiff
pcdl_plot_contour output/output00000021.xml oxygen
pcdl_plot_scatter output/output00000021.xml
pcdl_make_ome_tiff('output/')

Load jpeg, png, tiff, and ometiff files into a julia data structures

⚠ bue 2024-09-04: ome.tiff files currently cannot be loaded ( github issue: tlnagy/OMETIFF.jl#112 ).

We will use the Images library, and it's OMETIFF extension, to load jpeg, png, tiff, and ome.tiff files

Package installation.

using Pkg
Pkg.add("FileIO")
Pkg.add("Images")
Pkg.add("OMETIFF")

Load image file.

using FileIO
omeimg = load("output/timeseries_ID.ome.tiff")
img = load("output/cell_cell_type_z0.0/output00000021_cell_type.jpeg")

That's it!