Next changeset 1:dcfcad35e847 (2022-08-29) |
Commit message:
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5 |
added:
main_macros.xml mcmicro_to_anndata.py scimap_phenotyping.py scimap_phenotyping.xml scimap_spatial.py test-data/imc.h5ad test-data/manual_gates.csv test-data/mcmicro_output.csv test-data/phenotype_workflow.csv test-data/tutorial_data.h5ad test-data/tutorial_data_pheno.h5ad |
b |
diff -r 000000000000 -r 7ed4b55b11f7 main_macros.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main_macros.xml Tue Jul 19 20:29:22 2022 +0000 |
b |
@@ -0,0 +1,29 @@ +<macros> + <token name="@TOOL_VERSION@">0.0.1</token> + <token name="@VERSION_SUFFIX@">0</token> + <token name="@PROFILE@">20.01</token> + + <xml name="scimap_requirements"> + <requirements> + <container type="docker">quay.io/goeckslab/scimap:0.17.7</container> + <yield /> + </requirements> + </xml> + + <xml name="macro_stdio"> + <stdio> + <exit_code range="1:" level="fatal" description="Error occurred. Please check Tool Standard Error" /> + </stdio> + </xml> + + <xml name="scimap_spatial_options" token_label="spatial_aggregate"> + <section name="options" title="Advanced Options" expanded="false"> + <param argument="x_coordinate" type="text" value="X_centroid" optional="false" label="Column name containing the x-coordinates values" /> + <param argument="y_coordinate" type="text" value="Y_centroid" optional="false" label="Column name containing the y-coordinates values" /> + <yield/> + <param argument="imageid" type="text" value="imageid" optional="true" label="Column name of the column containing the image id" /> + <param argument="subset" type="text" value="" optional="true" label="Imageid of a single image to be subsetted for analyis" /> + <param argument="label" type="text" value="@LABEL@" optional="true" label="Key for the returned data" help="Stored in adata.obs" /> + </section> + </xml> +</macros> |
b |
diff -r 000000000000 -r 7ed4b55b11f7 mcmicro_to_anndata.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mcmicro_to_anndata.py Tue Jul 19 20:29:22 2022 +0000 |
[ |
@@ -0,0 +1,45 @@ +import argparse +import json +import warnings + +import scimap as sm + + +def main(inputs, outfile): + """ + Parameter + --------- + inputs : str + File path to galaxy tool parameter. + + outfile : str + File path to estimator. + """ + warnings.simplefilter('ignore') + + with open(inputs, 'r') as param_handler: + params = json.load(param_handler) + + image_path = params['image_path'] + drop_markers = params['drop_markers'] + if not drop_markers: + drop_markers = None + else: + drop_markers = [x.strip() for x in drop_markers.split(',')] + options = params['options'] + for k, v in options.items(): + if v == '': + options[k] = None + + adata = sm.pp.mcmicro_to_scimap(image_path, drop_markers=drop_markers, **options) + + adata.write(outfile) + + +if __name__ == '__main__': + aparser = argparse.ArgumentParser() + aparser.add_argument("-i", "--inputs", dest="inputs", required=True) + aparser.add_argument("-e", "--outfile", dest="outfile", required=True) + args = aparser.parse_args() + + main(args.inputs, args.outfile) |
b |
diff -r 000000000000 -r 7ed4b55b11f7 scimap_phenotyping.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scimap_phenotyping.py Tue Jul 19 20:29:22 2022 +0000 |
[ |
@@ -0,0 +1,73 @@ +import argparse +import warnings + +import pandas as pd +import scimap as sm +from anndata import read_h5ad + + +def main( + adata, + output, + gating_workflow, + gating_workflow_ext, + manual_gates=None, + manual_gates_ext=None, + rescale_plots=False +): + """ + Parameter + --------- + adata : str + File path to the input AnnData. + output : str + File path to the output AnnData. + gating_workflow : str + File path to the gating workflow. + gating_workflow_ext : str + Datatype for gating workflow, either 'csv' or 'tabular'. + manual_gates : str + File path to the munual gating. + manual_gates_ext : str + Datatype for munual gate, either 'csv' or 'tabular'. + rescale_plots : boolean + Save plots from rescaling. + """ + warnings.simplefilter('ignore') + + adata = read_h5ad(adata) + # Rescale data + if manual_gates: + sep = ',' if manual_gates_ext == 'csv' else '\t' + manual_gates = pd.read_csv(manual_gates, sep=sep) + + adata = sm.pp.rescale(adata, gate=manual_gates, save_fig=rescale_plots) + + # Phenotype cells + # Load the gating workflow + sep = ',' if gating_workflow_ext == 'csv' else '\t' + phenotype = pd.read_csv(gating_workflow, sep=sep) + adata = sm.tl.phenotype_cells(adata, phenotype=phenotype, label="phenotype") + + # Summary of the phenotyping + print(adata.obs['phenotype'].value_counts()) + + adata.write(output) + + +if __name__ == '__main__': + aparser = argparse.ArgumentParser() + aparser.add_argument("-a", "--adata", dest="adata", required=True) + aparser.add_argument("-o", "--output", dest="output", required=True) + aparser.add_argument("-g", "--gating_workflow", dest="gating_workflow", required=True) + aparser.add_argument("-s", "--gating_workflow_ext", dest="gating_workflow_ext", required=True) + aparser.add_argument("-m", "--manual_gates", dest="manual_gates", required=False) + aparser.add_argument("-S", "--manual_gates_ext", dest="manual_gates_ext", required=False) + aparser.add_argument("-p", "--rescale_plots", dest="rescale_plots", action="store_true", + default=False, required=False) + + args = aparser.parse_args() + + main(args.adata, args.output, args.gating_workflow, + args.gating_workflow_ext, args.manual_gates, + args.manual_gates_ext, args.rescale_plots) |
b |
diff -r 000000000000 -r 7ed4b55b11f7 scimap_phenotyping.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scimap_phenotyping.xml Tue Jul 19 20:29:22 2022 +0000 |
[ |
@@ -0,0 +1,75 @@ +<tool id="scimap_phenotyping" name="Single Cell Phenotyping" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@"> + <description>using scimap</description> + <macros> + <import>main_macros.xml</import> + </macros> + + <expand macro="scimap_requirements"/> + <expand macro="macro_stdio" /> + <version_command>echo "@VERSION@"</version_command> + <command> + <![CDATA[ + python '$__tool_directory__/scimap_phenotyping.py' + --adata '$anndata' + #if $manual_gates + --manual_gates '$manual_gates' + --manual_gates_ext '${manual_gates.ext}' + #end if + --gating_workflow '$gating_workflow' + --gating_workflow_ext '${gating_workflow.ext}' + #if $rescale_plots + --rescale_plots + #end if + --output '$output' + + ]]> + </command> + <configfiles> + <inputs name="inputs" /> + </configfiles> + <inputs> + <param name="anndata" type="data" format="h5ad" label="Select the input anndata" /> + <param name="manual_gates" type="data" format="tabular,csv" optional="true" label="Select the dataset containing manual gate information" help="First column as markers and second column as the gate values in log1p scale. If a marker is not included, auto gating + based on gaussian mixture modeling will be executed. Optional."/> + <param name="gating_workflow" type="data" format="tabular,csv" label="Select the dataset containing gating workflow" /> + <param name="rescale_plots" type="boolean" checked="false" label="Save the GMM gates plots If True"/> + </inputs> + <outputs> + <data format="h5ad" name="output" /> + <collection name="gmm_plots" type="list" label="${tool.name}: GMM-plots"> + <filter>rescale_plots</filter> + <discover_datasets pattern="__designation_and_ext__" directory="auto_gating" ext="png"/> + </collection> + </outputs> + <tests> + <test> + <param name="anndata" value="tutorial_data.h5ad" ftype="h5ad" /> + <param name="manual_gates" value="manual_gates.csv" ftype="csv" /> + <param name="gating_workflow" value="phenotype_workflow.csv" ftype="csv" /> + <output name="output"> + <assert_contents> + <has_h5_keys keys="obs/phenotype" /> + </assert_contents> + </output> + </test> + </tests> + <help> + <![CDATA[ +**What it does** + +This tool generates single cell phenotyping using either manual gating or auto gating (gaussian mixture modeling) implemented in Scimap. + +**Input** + +AnnData. + +**Output** + +Anndata with "obs/phenotype" added. + + + ]]> + </help> + <citations> + </citations> +</tool> |
b |
diff -r 000000000000 -r 7ed4b55b11f7 scimap_spatial.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scimap_spatial.py Tue Jul 19 20:29:22 2022 +0000 |
[ |
@@ -0,0 +1,59 @@ +import argparse +import json +import warnings + +import scimap as sm +from anndata import read_h5ad + + +def main(inputs, anndata, output): + """ + Parameter + --------- + inputs : str + File path to galaxy tool parameter. + anndata : str + File path to anndata containing phenotyping info. + output : str + File path to output. + """ + warnings.simplefilter('ignore') + + with open(inputs, 'r') as param_handler: + params = json.load(param_handler) + + adata = read_h5ad(anndata) + + tool = params['analyses']['selected_tool'] + tool_func = getattr(sm.tl, tool) + + options = params['analyses']['options'] + if tool == 'cluster': + options['method'] = params['analyses']['method'] + subset_genes = options.pop('subset_genes') + if subset_genes: + options['subset_genes'] = \ + [x.strip() for x in subset_genes.split(',')] + sub_cluster_group = options.pop('sub_cluster_group') + if sub_cluster_group: + options['sub_cluster_group'] = \ + [x.strip() for x in sub_cluster_group.split(',')] + + for k, v in options.items(): + if v == '': + options[k] = None + + tool_func(adata, **options) + + adata.write(output) + + +if __name__ == '__main__': + aparser = argparse.ArgumentParser() + aparser.add_argument("-i", "--inputs", dest="inputs", required=True) + aparser.add_argument("-e", "--output", dest="output", required=True) + aparser.add_argument("-a", "--anndata", dest="anndata", required=True) + + args = aparser.parse_args() + + main(args.inputs, args.anndata, args.output) |
b |
diff -r 000000000000 -r 7ed4b55b11f7 test-data/imc.h5ad |
b |
Binary file test-data/imc.h5ad has changed |
b |
diff -r 000000000000 -r 7ed4b55b11f7 test-data/manual_gates.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/manual_gates.csv Tue Jul 19 20:29:22 2022 +0000 |
b |
@@ -0,0 +1,19 @@ +markers,gate +ASMA,6.6 +CD163,6.6 +CD206,7.5 +CD68,6.2 +CD20,7.8 +CD21,8 +CD3D,6.5 +CD45,7.3 +CD56,8.7 +CD8A,6.5 +FOXP3,5.2 +CD11B,6.7 +CD11C,6.3 +CD15,7.9 +CD4,7.4 +PD1,7.9 +HLADR,6.7 +CD25,7 \ No newline at end of file |
b |
diff -r 000000000000 -r 7ed4b55b11f7 test-data/mcmicro_output.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/mcmicro_output.csv Tue Jul 19 20:29:22 2022 +0000 |
b |
b'@@ -0,0 +1,4826 @@\n+CellID,DNA1,BG1,BG2,BG3,DNA2,CD25,CD2,CD10,DNA3,CD163,CD3D,CD5,DNA4,CD30,ACTIN,CD45,DNA5,CD206,CD68,PD1,DNA6,KI67,CD11C,CD7,DNA7,CD8A,FOXP3,CD20,DNA8,CD4,HLADR,PSTAT3,DNA9,PS6,PERK,CD21,DNA10,CD43,NOS2,PDL1,DNA11,CD11B,CD57,MHCI,DNA12,CD15,ASMA,CD56,X_centroid,Y_centroid,Area,MajorAxisLength,MinorAxisLength,Eccentricity,Solidity,Extent,Orientation\r\n+1,16640.5641,719.6324786,527.7094017,1100.273504,14726.17094,581.5811966,618.3846154,1606.777778,7182.247863,509.3247863,477.5897436,1795.410256,10677.03419,1084.051282,5382.076923,2983.239316,3771.91453,1103.111111,399.3418803,2705.57265,7494.65812,1599.940171,757.7692308,451.6324786,8504.008547,389.8547009,109.042735,7809.042735,7239.435897,1408.564103,807.2393162,2814.196581,5718.74359,617.4273504,260.0598291,20362.76923,3721.222222,756.3589744,370.4615385,1334.666667,3247.74359,969.8034188,148.5726496,4133.598291,2508.555556,1085.735043,218.5470085,3170.470085,511.5555556,9.846153846,117,14.53227038,10.27362788,0.707260822,0.959016393,0.75,-0.695369483\r\n+2,16938.30097,686.5533981,469.3009709,1048.048544,14650.61165,565.8932039,442.2912621,1539.398058,7244.252427,496.8252427,484.9029126,1793.932039,10165.42718,1056.427184,3202.825243,2895.475728,3729.495146,1076.504854,352.3980583,2904.805825,6971.31068,5288.281553,725.8446602,433.0485437,8211.699029,380.2524272,101.9320388,4205.223301,7051.174757,1366.407767,998.4951456,2812.883495,5586.271845,594.7281553,244.7669903,5087.757282,3746,790.631068,349.2038835,1326.640777,3062.407767,867.8932039,143.3300971,2705.466019,2386.116505,1075.640777,164.4854369,3116.76699,579.3300971,9.398058252,103,16.0562861,8.776322775,0.837395595,0.903508772,0.613095238,1.115706828\r\n+3,16243.54167,819.4166667,604.3916667,1098.15,14324.90833,666.475,574.3333333,1759.683333,7296.325,548.05,494.1666667,1901.141667,10336.58333,1179.216667,3045.058333,2509.725,3901.975,1155.625,775.5916667,2448.65,7403.65,1932.808333,2533.725,477.5416667,8438.216667,389.1083333,109.1333333,4923.483333,7260.166667,1615.125,968.4166667,2785.666667,5864.183333,906.15,264.625,10590.6,4249.358333,781.4583333,368.4,1401.816667,3333.691667,1236.808333,150.7,4460.333333,2634.016667,1164.391667,227.7416667,3156.108333,630.9583333,12.88333333,120,15.2220045,10.31075603,0.735652971,0.975609756,0.681818182,0.151615546\r\n+4,20215.44295,695.3087248,444.5436242,1063.375839,17440.28188,558.5033557,408.5771812,1557.738255,8583.442953,472.3691275,347.0939597,1772.805369,12923.10067,1081.255034,4449.959732,3137.201342,4895.798658,1106,332.885906,2400.060403,8861.348993,2666.100671,125.0872483,419.2013423,10357.71812,384.3691275,103.8926174,6379.765101,8868.865772,1235.09396,794.7181208,2789.630872,6966.872483,547.4362416,244.6979866,5095.61745,5177.644295,710.738255,359.2483221,1279.228188,3952.899329,674.3087248,144.6845638,2517.95302,3096.026846,1097.530201,155.3624161,3090.751678,745.1946309,16.27516779,149,14.38020046,13.4047589,0.362026674,0.967532468,0.662222222,-0.270451448\r\n+5,17922.32934,685.9580838,521.6646707,1075.023952,15913.23952,562,524.4550898,1596.982036,8090.39521,482.0658683,372.8982036,1808.51497,11358.23952,1041.275449,3203.676647,2656.94012,4390.658683,1079.97006,315.6467066,2396.39521,7671.389222,2875.526946,122.8742515,427.508982,9384.772455,372.9041916,101.2754491,4407.814371,7981.209581,1239.616766,825.754491,2779.275449,6312.275449,514.5928144,251.3353293,18157.99401,4689.820359,725.508982,350.5628743,1326.952096,3575.724551,838.2155689,144.2275449,2677.179641,2866.928144,1107.874251,157.6047904,3074.137725,657.1736527,18.03592814,167,17.67583101,12.11010632,0.728428039,0.943502825,0.695833333,-0.810889758\r\n+6,16637.04942,666.9593023,432.4767442,1054.688953,14887.5407,558.5494186,536.3953488,1500.401163,7671.296512,489.2005814,665.7616279,1770.860465,10399.71512,1047.305233,3711.02907,3216.81686,3880.555233,1071.488372,315.7151163,3681.30814,7289.337209,3397.715116,100.9796512,511.1773256,8499.674419,373.2383721,102.1569767,4943.063953,7466.7732'..b',981.4204545,16357.47727,557.7045455,687.3295455,1381.409091,6497.295455,464.5909091,1087.954545,1708.022727,8616.204545,1064.079545,3466.704545,2985.647727,3181.965909,1032.340909,240.0340909,2393.147727,6480.659091,297.0454545,248.8295455,1392.738636,7762.011364,536.0795455,103.9659091,2944.659091,5869.909091,1975.034091,311.1704545,2774.715909,4753.454545,508.6136364,232.9545455,879.8863636,2242.443182,1146.852273,338.8977273,1270.75,1436.261364,599.4772727,145.2840909,1646.204545,1463.897727,1019.875,270.5,3031.022727,752.75,1087.875,88,12.88562484,9.253094799,0.69594573,0.897959184,0.666666667,0.957043206\r\n+4821,16663.31818,918.8896104,592.4220779,1113.168831,14460.98701,669.512987,551.6103896,1553.292208,6450.363636,570.5974026,743.5714286,1773.409091,8279.136364,1203.538961,2151.24026,2188.558442,3193.402597,1600.701299,283.2857143,2290.266234,7050.883117,374.8181818,199.7012987,1060.61039,8511.383117,471.6948052,110.8376623,2289.331169,6521.811688,1532.798701,298.3051948,2842.896104,5753.175325,595.7662338,249.8376623,1114.045455,2975.525974,988.7857143,384.8571429,1316.785714,1767.123377,604.5714286,155.0064935,3352.824675,1826.668831,1162.292208,518.961039,3162.61039,559.5974026,1091.577922,154,18.15030705,11.68328834,0.76528091,0.900584795,0.57037037,-0.342314995\r\n+4822,24303.67339,847.4919355,682.3991935,1087.040323,20231.05645,641.4959677,761.8145161,1550.205645,9459.254032,542.6048387,1148.193548,1756.467742,12225.40726,1147.822581,3659.919355,3115.084677,4849.274194,1120.846774,267.8024194,2366.669355,10215.43548,345.1048387,475.7096774,1330.322581,12767.6129,598.9516129,115.375,2522.350806,9422.931452,2069.883065,513.6935484,2786.955645,8182.576613,999.9677419,246.9475806,1026.133065,3994.149194,1323.616935,352.0967742,1324.274194,2428.96371,664.2862903,141.9274194,4181.064516,2517.875,1156.274194,511.3629032,3163.528226,619.983871,1092.959677,248,21.73441363,15.5658204,0.697912404,0.864111498,0.551111111,1.432242241\r\n+4823,28656.2561,878.2560976,585.3292683,1109,26340.39024,704.0731707,780.1707317,1667.987805,10873.62195,554.097561,917.597561,1754.121951,13894.54878,1200.146341,3076.402439,2854.682927,5523.829268,1184.47561,287.5365854,2339.085366,12032.81707,380.597561,234.695122,745.7926829,14771.08537,533.0487805,131.6219512,2374.512195,10363.86585,1905.060976,349.4146341,2797.317073,9098.963415,700.6341463,272.7560976,1087.865854,4526.353659,1215.573171,388.9268293,1316.890244,2884.390244,635.4268293,145.5609756,2076.585366,2662.47561,1233.182927,1243.54878,3194.195122,583.3170732,1093.573171,82,12.06003923,9.539788552,0.611784252,0.964705882,0.630769231,0.203022727\r\n+4824,22054.81818,685.8484848,424.8522727,999.3674242,19502,564.1212121,533.6401515,1392.80303,8292.32197,522.5,666.6287879,1670.159091,10429.95076,1008.814394,2310.219697,1606.685606,4121.117424,1026.170455,232.2878788,2289.689394,8755.742424,307.3939394,305.0530303,920.5757576,10190.22727,440.8939394,187.3295455,2048.893939,7579.159091,1631.219697,316.6780303,2784.416667,6559.219697,660.6287879,221.9734848,876.6439394,3082.431818,860.8030303,338.7878788,1294.844697,1929.806818,611.5265152,135.1818182,1765.609848,1834.310606,1031.242424,313.3257576,3038.810606,607.0643939,1101.583333,264,22.54949397,15.90532077,0.708857655,0.882943144,0.661654135,0.69183765\r\n+4825,23992.8526,850.2514451,529.8988439,1038.630058,18614.19075,589.2572254,482.265896,1413.858382,7905.135838,495.265896,572.5,1692.979769,10212.27746,1042.635838,2429.346821,1848.277457,3843.011561,1033.361272,243.0144509,2259.849711,8138.063584,1081.375723,194.1127168,673.8468208,9755.317919,408.5606936,100.1936416,3065.66763,7173.176301,1507.528902,315.8150289,2788.537572,6309.33526,562.4682081,221.1965318,922.517341,3052.216763,873.6907514,335.0635838,1286.430636,1860.872832,573.0144509,133.7456647,1829.913295,1734.875723,1000.557803,285.982659,3087.300578,641.5924855,1100.132948,346,23.1498058,19.37556441,0.547257266,0.945355191,0.791762014,-1.39051567\n\\ No newline at end of file\n' |
b |
diff -r 000000000000 -r 7ed4b55b11f7 test-data/phenotype_workflow.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/phenotype_workflow.csv Tue Jul 19 20:29:22 2022 +0000 |
b |
@@ -0,0 +1,23 @@ +,,ASMA,CD163,CD206,CD68,CD20,CD21,CD3D,CD45,CD56,CD8A,FOXP3,CD11B,CD11C,CD15,CD4,PD1,HLADR,CD25 +all,Other Immune cells,,,,,,,,pos,,,,,,,,,, +all,ASMA+ cells,pos,,,,,,,,,,,,,,,,, +Other Immune cells,T cells,,,,,,,pos,,,,,,,,,,, +Other Immune cells,B cells,,,,,pos,,,,,,,,,,,,, +Other Immune cells,Myeloid Lineage,,anypos,anypos,anypos,,,,,,,,anypos,anypos,,,,, +Other Immune cells,NK cells,,,,,,,,,pos,,,,,,,,, +Other Immune cells,Granulocytes,,,,,,,,,,,,,,pos,,,, +Myeloid Lineage,T cells,,,,,,,pos,,,,,,,,,,, +Myeloid Lineage,B cells,,,,,pos,,,,,,,,,,,,, +Myeloid Lineage,NK cells,,,,,,,,,pos,,,,,,,,, +Myeloid Lineage,Granulocytes,,,,,,,,,,,,,,pos,,,, +T cells,CD4 T cells,,,,,,,,,,,,,,,pos,,, +T cells,CD8 T cells,,,,,,,,,,pos,,,,,,,, +CD4 T cells,Regulatory T cells,,,,,,,,,,,pos,,,,,,, +CD4 T cells,Follicular Helper T cells,,,,,,,,,,,,,,,,pos,, +CD8 T cells,PD1+ T cells,,,,,,,,,,,,,,,,pos,, +Myeloid Lineage,CD68+ Macrophages,,,,pos,,,,,,,,,,,,,, +Myeloid Lineage,M2 Macrophages,,anypos,anypos,,,,,,,,,,,,,,, +Myeloid Lineage,Myeloid Dendritic cells,,,,,,,,,,,,,,,,,pos, +Myeloid Lineage,Follicular Dendritic cells,,,,,,pos,,,,,,,,,,,, +CD68+ Macrophages,M1 Macrophages,,,,,,,,,,,,,,,,,pos, +Myeloid Dendritic cells,CD25+ Dendritic cells,,,,,,,,,,,,,,,,,,pos \ No newline at end of file |
b |
diff -r 000000000000 -r 7ed4b55b11f7 test-data/tutorial_data.h5ad |
b |
Binary file test-data/tutorial_data.h5ad has changed |
b |
diff -r 000000000000 -r 7ed4b55b11f7 test-data/tutorial_data_pheno.h5ad |
b |
Binary file test-data/tutorial_data_pheno.h5ad has changed |