| Previous changeset 6:2dc244356765 (2023-11-13) Next changeset 8:c297f2961ee5 (2026-03-06) |
|
Commit message:
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/curve_fitting/ commit 1a195a2260539d6f5fe4dbdd019b0f1c2b9a33f5 |
|
modified:
curve_fitting.py curve_fitting.xml |
|
added:
creators.xml test-data/input1.tsv test-data/input2.tsv test-data/output1/curve1.tsv test-data/output2/curve1.tsv test-data/output2/curve2.tsv |
|
removed:
test-data/curves_fitted.xlsx test-data/spots_linked.xlsx |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae creators.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/creators.xml Thu Feb 19 20:52:09 2026 +0000 |
| b |
| @@ -0,0 +1,43 @@ +<macros> + + <xml name="creators/bmcv"> + <organization name="Biomedical Computer Vision Group, Heidelberg Universtiy" alternateName="BMCV" url="http://www.bioquant.uni-heidelberg.de/research/groups/biomedical_computer_vision.html" /> + <yield /> + </xml> + + <xml name="creators/kostrykin"> + <person givenName="Leonid" familyName="Kostrykin"/> + <yield/> + </xml> + + <xml name="creators/rmassei"> + <person givenName="Riccardo" familyName="Massei"/> + <yield/> + </xml> + + <xml name="creators/alliecreason"> + <person givenName="Allison" familyName="Creason"/> + <yield/> + </xml> + + <xml name="creators/bugraoezdemir"> + <person givenName="Bugra" familyName="Oezdemir"/> + <yield/> + </xml> + + <xml name="creators/thawn"> + <person givenName="Till" familyName="Korten"/> + <yield/> + </xml> + + <xml name="creators/pavanvidem"> + <person givenName="Pavan" familyName="Videm"/> + <yield/> + </xml> + + <xml name="creators/tuncK"> + <person givenName="Tunc" familyName="Kayikcioglu"/> + <yield/> + </xml> + +</macros> |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae curve_fitting.py --- a/curve_fitting.py Mon Nov 13 22:11:00 2023 +0000 +++ b/curve_fitting.py Thu Feb 19 20:52:09 2026 +0000 |
| [ |
| @@ -8,6 +8,7 @@ """ import argparse +import os import numpy as np import pandas as pd @@ -51,13 +52,15 @@ return compute_curve(xx, result.x) -def curve_fitting_io(fn_in, fn_out, degree=2, penalty='abs', alpha=0.01): - # read all sheets - xl = pd.ExcelFile(fn_in) - nSpots = len(xl.sheet_names) - data_all = [] +def curve_fitting_io(input_list, output, degree=2, penalty='abs', alpha=0.01): + + # read all inputs + nSpots = len(input_list) + df_all, data_all = [], [] for i in range(nSpots): - df = pd.read_excel(xl, xl.sheet_names[i]) + df = pd.read_csv(input_list[i], delimiter='\t') + df.columns = df.columns.str.strip() # remove whitespaces from header names + df_all.append(df) data_all.append(np.array(df)) col_names = df.columns.tolist() ncols_ori = len(col_names) @@ -65,7 +68,7 @@ # curve_fitting diff = np.array([], dtype=('float64')) for i in range(nSpots): - seq = data_all[i][:, -1] + seq = data_all[i][:, col_names.index('intensity')] seq_fit = seq.copy() idx_valid = ~np.isnan(seq) seq_fit[idx_valid] = curve_fitting(seq[idx_valid], degree=degree, penalty=penalty) @@ -82,25 +85,21 @@ seq_assist = data_all[i][:, -1] + sig3 data_all[i] = np.concatenate((data_all[i], seq_assist.reshape(-1, 1)), axis=1) - # write to file - with pd.ExcelWriter(fn_out) as writer: - for i in range(nSpots): - df = pd.DataFrame() - for c in range(ncols_ori): - df[col_names[c]] = data_all[i][:, c] - df['CURVE'] = data_all[i][:, ncols_ori] - if alpha > 0: - df['CURVE_A'] = data_all[i][:, ncols_ori + 1] - df.to_excel(writer, sheet_name=xl.sheet_names[i], index=False, float_format='%.2f') - writer.save() + # write to files + for i in range(nSpots): + df = df_all[i] + df['curve'] = data_all[i][:, ncols_ori] + if alpha > 0: + df['curve_a'] = data_all[i][:, ncols_ori + 1] + df.to_csv(os.path.join(output, f'curve{i + 1}.tsv'), sep='\t', lineterminator='\n', index=False) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Fit (1st- or 2nd-degree) polynomial curves to data points") - parser.add_argument("fn_in", help="File name of input data points (xlsx)") - parser.add_argument("fn_out", help="File name of output fitted curves (xlsx)") + parser.add_argument("--input", help="File name of input data points (tsv)", action='append', type=str, required=True) + parser.add_argument("output", help="Name of output directory") parser.add_argument("degree", type=int, help="Degree of the polynomial function") parser.add_argument("penalty", help="Optimization objective for fitting") parser.add_argument("alpha", type=float, help="Significance level for generating assistive curves") args = parser.parse_args() - curve_fitting_io(args.fn_in, args.fn_out, args.degree, args.penalty, args.alpha) + curve_fitting_io(args.input, args.output, args.degree, args.penalty, args.alpha) |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae curve_fitting.xml --- a/curve_fitting.xml Mon Nov 13 22:11:00 2023 +0000 +++ b/curve_fitting.xml Thu Feb 19 20:52:09 2026 +0000 |
| [ |
| @@ -1,5 +1,11 @@ -<tool id="ip_curve_fitting" name="Perform curve fitting" version="0.0.3-2" profile="20.05"> +<tool id="ip_curve_fitting" name="Perform curve fitting" version="0.0.4" profile="20.05"> <description></description> + <macros> + <import>creators.xml</import> + </macros> + <creator> + <expand macro="creators/bmcv"/> + </creator> <edam_operations> <edam_operation>operation_3443</edam_operation> </edam_operations> @@ -7,23 +13,31 @@ <xref type="bio.tools">galaxy_image_analysis</xref> </xrefs> <requirements> - <requirement type="package" version="1.20.2">numpy</requirement> - <requirement type="package" version="3.0.7">openpyxl</requirement> - <requirement type="package" version="1.2.4">pandas</requirement> - <requirement type="package" version="1.6.2">scipy</requirement> + <requirement type="package" version="2.3.5">numpy</requirement> + <requirement type="package" version="2.2.2">pandas</requirement> + <requirement type="package" version="1.16.3">scipy</requirement> </requirements> <command> <![CDATA[ -python '$__tool_directory__/curve_fitting.py' - '$fn_in' - ./output.xlsx - $degree - $penalty - $alpha + + mkdir ./output && + python '$__tool_directory__/curve_fitting.py' + + #for $input in $input_list + #if $input + --input '$input' + #end if + #end for + + ./output + $degree + $penalty + $alpha + ]]> </command> <inputs> - <param name="fn_in" type="data" format="xlsx" label="File name of input data points (xlsx)" /> + <param name="input_list" type="data" format="tsv,tabular" multiple="true" label="Lists of intensity values"/> <param name="degree" type="select" label="Degree of the polynomial function"> <option value="2" selected="True">2nd degree</option> <option value="1">1st degree</option> @@ -36,21 +50,39 @@ <param name="alpha" type="float" value="0.01" label="Significance level for generating assistive curves" /> </inputs> <outputs> - <data format="xlsx" name="fn_out" from_work_dir="output.xlsx"/> + <collection type="list" name="output" label="Curve fitting on ${on_string}"> + <discover_datasets directory="output" pattern="__name__" format="tsv"/> + </collection> </outputs> <tests> <test> - <param name="fn_in" value="spots_linked.xlsx"/> + <param name="input_list" value="input1.tsv"/> <param name="degree" value="2"/> <param name="penalty" value="abs"/> <param name="alpha" value="0.01"/> - <output name="fn_out" value="curves_fitted.xlsx" ftype="xlsx" compare="sim_size"/> + <output_collection name="output" type="list" count="1"> + <element name="curve1.tsv" value="output1/curve1.tsv" ftype="tsv" compare="diff"/> + </output_collection> + </test> + <test> + <param name="input_list" value="input1.tsv,input2.tsv"/> + <param name="degree" value="2"/> + <param name="penalty" value="abs"/> + <param name="alpha" value="0.01"/> + <output_collection name="output" type="list" count="2"> + <element name="curve1.tsv" value="output2/curve1.tsv" ftype="tsv" compare="diff"/> + <element name="curve2.tsv" value="output2/curve2.tsv" ftype="tsv" compare="diff"/> + </output_collection> </test> </tests> <help> - **What it does** + + **Perform curve fitting for lists of intensity values.** - This tool fits (1st- or 2nd-degree) polynomial curves to data points. Optional: Given a significance level, assistive curves will also be generated. + This tool fits 1st- or 2nd-order polynomial curves to 1-D data points (tabular list of values). + + Optionally, given a significance level, assistive curves are generated. + </help> <citations> <citation type="doi">10.1097/j.pain.0000000000002642</citation> |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae test-data/curves_fitted.xlsx |
| b |
| Binary file test-data/curves_fitted.xlsx has changed |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae test-data/input1.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/input1.tsv Thu Feb 19 20:52:09 2026 +0000 |
| b |
| @@ -0,0 +1,26 @@ +frame pos_x pos_y intensity +1 199 265 48533.56 +2 199 265 55939.36 +3 199 265 59098.11 +4 199 265 54234.74 +5 198 265 52396.98 +6 199 265 55937.6 +7 199 265 54341.73 +8 199 265 51470.92 +9 199 265 52983.33 +10 199 265 53354.71 +11 199 265 53435.04 +12 199 266 54853.97 +13 199 266 51723.82 +14 199 268 55421.12 +15 199 268 52665.4 +16 199 267 52337.47 +17 199 268 55327.1 +18 199 269 48798.69 +19 199 267 52500.61 +20 199 267 53049.55 +21 199 267 53916.84 +22 199 266 50521.86 +23 199 267 48872.79 +24 199 267 49995.33 +25 199 267 51935.29 |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae test-data/input2.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/input2.tsv Thu Feb 19 20:52:09 2026 +0000 |
| b |
| @@ -0,0 +1,17 @@ +frame pos_x pos_y intensity +3 199 268 53383.42 +4 199 269 56658.14 +5 199 269 54199.83 +6 199 269 54090.9 +7 200 268 54382.22 +8 200 269 54957.7 +9 200 270 51870.16 +10 199 269 46656.38 +11 200 269 50855.08 +12 202 273 39033.58 +13 204 273 32915.16 +14 203 272 30327.51 +15 204 272 34846.82 +16 204 272 36178.4 +17 204 273 31739.84 +18 204 273 31831.22 |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae test-data/output1/curve1.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/output1/curve1.tsv Thu Feb 19 20:52:09 2026 +0000 |
| b |
| @@ -0,0 +1,26 @@ +frame pos_x pos_y intensity curve curve_a +1 199 265 48533.56 54364.28694031549 60195.013880630984 +2 199 265 55939.36 54335.31702432827 60166.043964643766 +3 199 265 59098.11 54292.13495728906 60122.861897604555 +4 199 265 54234.74 54234.74073919788 60065.46767951337 +5 198 265 52396.98 54163.13437005471 59993.8613103702 +6 199 265 55937.6 54077.31584985955 59908.042790175045 +7 199 265 54341.73 53977.285178612416 59808.01211892791 +8 199 265 51470.92 53863.04235631329 59693.76929662879 +9 199 265 52983.33 53734.587382962185 59565.31432327768 +10 199 265 53354.71 53591.9202585591 59422.64719887459 +11 199 265 53435.04 53435.04098310402 59265.76792341952 +12 199 266 54853.97 53263.94955659697 59094.67649691246 +13 199 266 51723.82 53078.64597903793 58909.372919353424 +14 199 268 55421.12 52879.130250426904 58709.8571907424 +15 199 268 52665.4 52665.40237076389 58496.129311079385 +16 199 267 52337.47 52437.4623400489 58268.18928036439 +17 199 268 55327.1 52195.31015828192 58026.037098597415 +18 199 269 48798.69 51938.945825462964 57769.67276577846 +19 199 267 52500.61 51668.36934159202 57499.096281907514 +20 199 267 53049.55 51383.58070666909 57214.307646984584 +21 199 267 53916.84 51084.579920694174 56915.30686100967 +22 199 266 50521.86 50771.36698366728 56602.09392398277 +23 199 267 48872.79 50443.9418955884 56274.668835903896 +24 199 267 49995.33 50102.30465645754 55933.031596773035 +25 199 267 51935.29 49746.455266274694 55577.18220659019 |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae test-data/output2/curve1.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/output2/curve1.tsv Thu Feb 19 20:52:09 2026 +0000 |
| b |
| @@ -0,0 +1,26 @@ +frame pos_x pos_y intensity curve curve_a +1 199 265 48533.56 54364.28694031549 63253.283100868255 +2 199 265 55939.36 54335.31702432827 63224.313184881044 +3 199 265 59098.11 54292.13495728906 63181.131117841825 +4 199 265 54234.74 54234.74073919788 63123.73689975064 +5 198 265 52396.98 54163.13437005471 63052.13053060748 +6 199 265 55937.6 54077.31584985955 62966.31201041232 +7 199 265 54341.73 53977.285178612416 62866.28133916519 +8 199 265 51470.92 53863.04235631329 62752.03851686606 +9 199 265 52983.33 53734.587382962185 62623.58354351495 +10 199 265 53354.71 53591.9202585591 62480.91641911186 +11 199 265 53435.04 53435.04098310402 62324.037143656795 +12 199 266 54853.97 53263.94955659697 62152.945717149734 +13 199 266 51723.82 53078.64597903793 61967.642139590695 +14 199 268 55421.12 52879.130250426904 61768.126410979676 +15 199 268 52665.4 52665.40237076389 61554.39853131666 +16 199 267 52337.47 52437.4623400489 61326.45850060167 +17 199 268 55327.1 52195.31015828192 61084.306318834686 +18 199 269 48798.69 51938.945825462964 60827.941986015736 +19 199 267 52500.61 51668.36934159202 60557.36550214479 +20 199 267 53049.55 51383.58070666909 60272.576867221855 +21 199 267 53916.84 51084.579920694174 59973.57608124694 +22 199 266 50521.86 50771.36698366728 59660.36314422004 +23 199 267 48872.79 50443.9418955884 59332.93805614117 +24 199 267 49995.33 50102.30465645754 58991.30081701031 +25 199 267 51935.29 49746.455266274694 58635.451426827465 |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae test-data/output2/curve2.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/output2/curve2.tsv Thu Feb 19 20:52:09 2026 +0000 |
| b |
| @@ -0,0 +1,17 @@ +frame pos_x pos_y intensity curve curve_a +3 199 268 53383.42 57769.32742699415 66658.32358754691 +4 199 269 56658.14 56658.1393275885 65547.13548814127 +5 199 269 54199.83 55431.86482503778 64320.86098559055 +6 199 269 54090.9 54090.50391934199 62979.50007989476 +7 200 268 54382.22 52634.05661050111 61523.05277105387 +8 200 269 54957.7 51062.52289851515 59951.51905906791 +9 200 270 51870.16 49375.90278338412 58264.89894393689 +10 199 269 46656.38 47574.196265108 56463.192425660774 +11 200 269 50855.08 45657.403343686805 54546.39950423957 +12 202 273 39033.58 43625.524019120545 52514.520179673316 +13 204 273 32915.16 41478.558291409194 50367.55445196196 +14 203 272 30327.51 39216.506160552766 48105.50232110554 +15 204 272 34846.82 36839.36762655126 45728.36378710403 +16 204 272 36178.4 34347.142689404674 43236.13884995744 +17 204 273 31739.84 31739.831349113017 40628.82750966579 +18 204 273 31831.22 29017.433605676277 37906.42976622905 |
| b |
| diff -r 2dc244356765 -r 91dfd38a97ae test-data/spots_linked.xlsx |
| b |
| Binary file test-data/spots_linked.xlsx has changed |