Package: pyfish
PyFishPyFish is a Python 3 package for creation ofFish (Muller) plotslike the one below.Primary featurespolynomial interpolationcurve smoothinghigh performanceworks with low and high density dataPyFish can be used either as a stand-alone tool or as a plotting library.InstallationPyFish requires Python >= 3.8The package can be installed using Conda (from the bioconda channel)conda install -c bioconda pyfishor Pippip install pyfish.InputThe program takes two tables:one describing the size of individual subgroups at given points in time, referred to aspopulations,one describing the parent-child relationships between the subgroups, referred to asparent tree.PopulationsPopulations table has the schema(Id: +int, Step: +int, Pop: +int), where:Idis a numerical identifier of a subgroup`,Stepis a natural ordinal describing the logical time when the population is measured,Popis the size of the population of the subgroup at the given step.An example populations table:IdStepPop0010001400220030101013501510024202550301031203510Parent TreeParent tree has the schema(ParentId: +int, ChildId: +int), where:ParentIdis an id matching the population table,ChildIdis an id matching the population table describing the direct progeny of the parent.An example parent tree:ParentIdChildId011203Note: there must be exactly one node in the parent tree that has no parent. This is the root (0 in the example above).ToolWe provide example data. From the root folder of the project call:pyfish tests/populations.csv tests/parent_tree.csv out.pngThis will create a plot calledout.pngin the folder.Additional execution parameters are described below.LibraryThe populations and parent_tree tables can be constructed directly as dataframes.The library contains three public functions:process_dataTakes the input data and parameters and creates data suitable for plotting.
Additional arguments match the parameters as described below.setup_figureResizes the figure and adds labels for axes.fish_plotCalls the plotting function on the input parameters.Example:importmatplotlib.pyplotaspltimportnumpyasnpimportpandasaspdfrompyfishimportfish_plot,process_data,setup_figurepopulations=np.array([[0,0,100],[0,1,40],[0,2,20],[0,3,0],[1,0,10],[1,3,50],[1,5,100],[2,4,20],[2,5,50],[3,0,10],[3,1,20],[3,5,10]])parent_tree=np.array([[0,1],[1,2],[0,3]])populations_df=pd.DataFrame(populations,columns=["Id","Step","Pop"])parent_tree_df=pd.DataFrame(parent_tree,columns=["ParentId","ChildId"])data=process_data(populations_df,parent_tree_df)setup_figure()fish_plot(*data)plt.show()Calling the above code displays the following image:Parameters-a, --absolutePlots absolute population counts at each step.Base--absolute-I, --interpolate intFills in missing values by interpolation by a polynomial of the given degree.
If a value is not given, each population is set to 0 at the first and last step.Base--interpolate 2-S, --smooth floatSmoothing of the graph using Gaussian filter.
The parameter value is the standard deviation of the kernel.
The bigger the population the bigger the value should be.NOTE: If the population values are sparse, using smoothing without interpolation might lead to misleading population sizes.Base--smooth 50-F, --first int+,-L, --last int+Only limits the steps to the range[first, last]inclusive.Base--first 4000 --last 4500-M, --cmap stringUse the specifiedmatplotlib colormap.Default colormap is rainbow.Base--cmap viridis-C, --color_by stringColor the ids based on a separate column in the populations.csv file.
It will select the first value of the column per id, so the value should be constant for all entries with the same id.Best combined with a sequential colormap using--cmapBase--color-by Feature --cmap viridis-R, --seed int+Specifies the seed for the randomization of colors.Base--seed 2022-W, --width int+,-H, --height int+Specifies the dimensions for the output image. The size is including the axes' labels.CitationPlease cite as:Adam Streck, Tom L Kaufmann, Roland F Schwarz, SMITH: Spatially Constrained Stochastic Model for Simulation of Intra-Tumour Heterogeneity, Bioinformatics, 2023;https://doi.org/10.1093/bioinformatics/btad102ContactEmail questions, feature requests and bug reports to Adam Streck,adam.streck@mdc-berlin.de.LicensePyFish is available under the MIT License.DevelopmentTo actively develop the package, we recommend to install pyfish in development mode using pippip install -e . --user.
In order to run the main routine from the command line without installing it first, runpython -m pyfish.main -- tests/populations.csv tests/parent_tree.csv out.png.To trigger testing, runpytest -v ..