Package: raman-opu-analysis
Raman OPU AnalysisAn Operational phenotypic unit (OPU) analysis library for Raman single-cell
spectroscopy dataDependenciesThis library requirespython>=3.6; below packages are also required:numpy, scipy, scikit-learnmatplotlibskfeature [1][1]: the original repo contains a bug in laplacian score; in the installation
below the actual package used (skfeature-gli) can be found at
(https://github.com/lguangyu/scikit-feature.git)InstallationThe installation is as easy as a single-line command:pip install raman-opu-analysisSynopsis and Basic Command-line UsageThis package provide main command-line scripts:opu_analysis: the main analysis scriptopu_transform_labspec_txt: a supporting script that converts txt dumps from LabSpec into the tabular format needed by this package.opu_spectra_preview: a convenient visualization of spectra datasetOPU AnalysisThe library can be used both in CLI, Jupyter notebook or with another python
library. The example below shows the usage in CLI as a standalone script:If you have already preparedParepare the Dataset Config FileA json config file need to be prepared before using theopu_analysisscript.
The config is a list of biosample configs, in the following structure:[{#biosample-1configs},{#biosample-2configs},...#repeattoaddmore]Each of the biosample config contains 3 keys-value paris:name: name of the biosample, will be shown in outputscolor: color of the biosample, currently only used in the HCA plot, in
the standard HTML format (#RRGGBB)file: the tabular data file(s) belong to the biosample, it can be a string
(as the path to the data file) or a list (paths to the data files).An example is:{"name":"biosample-1","color":"#0000ff","file":"biosample-1.data.tsv"}Another example withfilebeing a list:{"name":"biosample-2","color":"#0000ff","file":["biosample-2.data_1.tsv","biosample-2.data_2.tsv"]}All files in that list will be combined under the related biosample, and will
not be distinguished unless investigating the spectra names in outputs.An functional example of such config json can be found indoc/example.json.AnalysisHere we use the example provided in thedocdirectory.
Firstcd docto enter the directory,
then call the following command in terminal:opu_analysisexample.json\-b5.0-L400-H1800-Nl2\--metriccosine\--cutoff-threshold0.7\--opu-min-size0.05\--opu-labelsexample.json.opu_labels.txt\--opu-collection-prefixexample.json.opu_collection\--opu-hca-plotexample.json.hca.png\--abund-tableexample.json.opu_abund.tsv\--abund-alpha-diversityexample.json.opu_alpha_diversity.tsv\--abund-stackbar-plotexample.json.opu_abund.png\--abund-biplotexample.json.opu_pca.png\--feature-rank-methodfisher_score\--feature-rank-tableexample.json.opu_feature_rank.tsv\--feature-rank-plotexample.json.opu_feature_rank.pngA full set of output will be generated in thedocfolder.Convert LabSpec txt DumpsData in LabSpec txt dump format needs to be converted into the tabular format.
The LabSpec format is 2-column tab-delimited table, similar to followings:401.23	0.39
402.56	0.01
...The first column is wavenumber and the second column is intensity,
and each file encodes only one spectrum.
To convert multiple spectra into a single file, first organize them under a same
directory (e.g.inputdir), and run following:opu_transform_labspec_txt\-xtxt-b5-L400-H1800-Nl2\-ooutput.data.tsv\inputdirThe program will scan theinputdirfolder and discover all files with an
extension oftxt, then combine them into a single fileoutput.data.tsv.
Other parameters in the above example instruct the program to bin the
wavenumbers using a window size of 5, extract only the 400-1800 cm-1 wavenumber
range, and do an l2-normalization per spectrum. These additional data processing
parameters are optional, however the binning parameter (-b/--bin-size) is high
recommended. This option will force aligning and unify the wavenumbers dicovered
in multiple spectrum files. In case the bin size is not given (indicating no
binning will be performed) but the wavenumbers in different input spetrum files
are different, an error will occur.Jupyter Notebook UsageTo use this package in Jupyter notebook or as a library for integrating with
other analysis pipelines, simply do:fromopu_analysis_libimportOPUAnalysisThe detailed analysis and function calls are stated indoc/example.ipynb.