Mercurial > repos > perssond > quantification
annotate ParseInput.py @ 1:aba3655fdef0 draft
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
author | watsocam |
---|---|
date | Fri, 11 Mar 2022 23:35:52 +0000 |
parents | 928db0f952e3 |
children |
rev | line source |
---|---|
0
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
1 #Functions for parsing command line arguments for ome ilastik prep |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
2 import argparse |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
3 |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
4 |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
5 def ParseInputDataExtract(): |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
6 """Function for parsing command line arguments for input to single-cell |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
7 data extraction""" |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
8 |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
9 #if __name__ == '__main__': |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
10 parser = argparse.ArgumentParser() |
1
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
11 parser.add_argument('--masks',nargs='+', required=True) |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
12 parser.add_argument('--image', required=True) |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
13 parser.add_argument('--channel_names', required=True) |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
14 parser.add_argument('--output', required=True) |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
15 parser.add_argument( |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
16 '--mask_props', nargs = "+", |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
17 help=""" |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
18 Space separated list of additional metrics to be calculated for every mask. |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
19 This is for metrics that depend only on the cell mask. If the metric depends |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
20 on signal intensity, use --intensity-props instead. |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
21 See list at https://scikit-image.org/docs/dev/api/skimage.measure.html#regionprops |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
22 """ |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
23 ) |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
24 parser.add_argument( |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
25 '--intensity_props', nargs = "+", |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
26 help=""" |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
27 Space separated list of additional metrics to be calculated for every marker separately. |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
28 By default only mean intensity is calculated. |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
29 If the metric doesn't depend on signal intensity, use --mask-props instead. |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
30 See list at https://scikit-image.org/docs/dev/api/skimage.measure.html#regionprops |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
31 Additionally available is gini_index, which calculates a single number |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
32 between 0 and 1, representing how unequal the signal is distributed in each region. |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
33 See https://en.wikipedia.org/wiki/Gini_coefficient |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
34 """ |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
35 ) |
0
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
36 #parser.add_argument('--suffix') |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
37 args = parser.parse_args() |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
38 #Create a dictionary object to pass to the next function |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
39 dict = {'masks': args.masks, 'image': args.image,\ |
1
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
40 'channel_names': args.channel_names,'output':args.output, |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
41 'intensity_props': set(args.intensity_props if args.intensity_props is not None else []).union(["intensity_mean"]), |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
42 'mask_props': args.mask_props, |
aba3655fdef0
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit 897a7dc7cb43e45d6f0fdfe2b2970e59f20f8853"
watsocam
parents:
0
diff
changeset
|
43 } |
0
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
44 #Print the dictionary object |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
45 print(dict) |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
46 #Return the dictionary |
928db0f952e3
"planemo upload for repository https://github.com/ohsu-comp-bio/quantification commit a4349062e9177b5e60fb7c49115c57299e0d648d-dirty"
perssond
parents:
diff
changeset
|
47 return dict |