multivariate_stats Package¶
multivariate_stats
Package¶
Multivariate statistics analysis
-
class
omsi.analysis.multivariate_stats.
omsi_nmf
(name_key='undefined')¶ Bases:
omsi.analysis.base.analysis_base
Class defining a basic nmf analysis.
The function has primarily been tested we MSI datasets but should support arbitrary n-D arrays (n>=2). The last dimension of the input array must be the spectrum dimnensions.
Initalize the basic data members
-
execute_analysis
()¶ Execute the nmf for the given msidata
-
classmethod
v_qmz
(analysis_object, qslice_viewer_option=0, qspectrum_viewer_option=0)¶ Implement support for qmz URL requests for the viewer
-
classmethod
v_qslice
(analysis_object, z, viewer_option=0)¶ Implement support for qslice URL requests for the viewer
-
classmethod
v_qslice_viewer_options
(analysis_object)¶ Define which viewer_options are supported for qspectrum URL’s
-
classmethod
v_qspectrum
(analysis_object, x, y, viewer_option=0)¶ Implement support for qspectrum URL requests for the viewer
-
classmethod
v_qspectrum_viewer_options
(analysis_object)¶ Define which viewer_options are supported for qspectrum URL’s
-
-
class
omsi.analysis.multivariate_stats.
omsi_cx
(name_key='undefined')¶ Bases:
omsi.analysis.base.analysis_base
Class used to implement CX factorization on MSI data.
Initalize the basic data members
-
classmethod
comp_lev_exact
(A, k, axis)¶ This function computes the column or row leverage scores of the input matrix.
Parameters: - A – n-by-d matrix
- k – rank parameter, k <= min(n,d)
- axis – 0: compute row leverage scores; 1: compute column leverage scores.
Returns: 1D array of leverage scores. If axis = 0, the length of lev is n. otherwise, the length of lev is d.
-
dimension_index
= {'pixelDim': 1, 'imageDim': 0}¶
-
execute_analysis
()¶ EDIT_ME:
Replace this text with the appropriate documentation for the analysis. Describe what your analysis does and how a user can use it. Note, a user will call the function execute(...) which takes care of storing parameters, collecting execution data etc., so that you only need to implement your analysis, the rest is taken care of by analysis_base. omsi uses Sphynx syntax for the documentation.
Keyword Arguments:
Parameters: mydata – ...
-
classmethod
v_qmz
(analysis_object, qslice_viewer_option=0, qspectrum_viewer_option=0)¶ Get the mz axes for the analysis
Parameters: - analysis_object – The omsi_file_analysis object for which slicing should be performed
- qslice_viewer_option – If multiple default viewer behaviors are available for a given analysis then this option is used to switch between them for the qslice URL pattern.
- qspectrum_viewer_option – If multiple default viewer behaviors are available for a given analysis then this option is used to switch between them for the qspectrum URL pattern.
Returns: The following four arrays are returned by the analysis:
- mz_spectra : Array with the static mz values for the spectra.
- label_spectra : Lable for the spectral mz axis
- mz_slice : Array of the static mz values for the slices or None if identical to the mz_spectra.
- label_slice : Lable for the slice mz axis or None if identical to label_spectra.
-
classmethod
v_qslice
(analysis_object, z, viewer_option=0)¶ Get 3D analysis dataset for which z-slices should be extracted for presentation in the OMSI viewer
Parameters: - analysis_object – The omsi_file_analysis object for which slicing should be performed
- z – Selection string indicting which z values should be selected.
- viewer_option – If multiple default viewer behaviors are available for a given analysis then this option is used to switch between them.
Returns: numpy array with the data to be displayed in the image slice viewer. Slicing will be performed typically like [:,:,zmin:zmax].
-
classmethod
v_qslice_viewer_options
(analysis_object)¶ Get a list of strings describing the different default viewer options for the analysis for qslice. The default implementation tries to take care of handling the spectra retrieval for all the depencies but can naturally not decide how the qspectrum should be handled by a derived class. However, this implementation is often called at the end of custom implementations to also allow access to data from other dependencies.
Parameters: analysis_object – The omsi_file_analysis object for which slicing should be performed. For most cases this is not needed here as the support for slice operations is usually a static decision based on the class type, however, in some cases additional checks may be needed (e.g., ensure that the required data is available). Returns: List of strings indicating the different available viewer options. The list should be empty if the analysis does not support qslice requests (i.e., v_qslice(...) is not available).
-
classmethod
v_qspectrum
(analysis_object, x, y, viewer_option=0)¶ Get from which 3D analysis spectra in x/y should be extracted for presentation in the OMSI viewer
- Developer Note: h5py currently supports only a single index list. If the user provides an index-list for both
- x and y, then we need to construct the proper merged list and load the data manually, or if the data is small enough, one can load the full data into a numpy array which supports mulitple lists in the selection.
Parameters: - analysis_object – The omsi_file_analysis object for which slicing should be performed
- x – x selection string
- y – y selection string
- viewer_option – If multiple default viewer behaviors are available for a given analysis then this option is used to switch between them.
Returns: The following two elemnts are expected to be returned by this function :
- 1D, 2D or 3D numpy array of the requested spectra. NOTE: The mass (m/z) axis must be the last axis. For index selection x=1,y=1 a 1D array is usually expected. For indexList selections x=[0]&y=[1] usually a 2D array is expected. For ragne selections x=0:1&y=1:2 we one usually expects a 3D array.
- None in case that the spectra axis returned by v_qmz are valid for the returned spectrum. Otherwise, return a 1D numpy array with the m/z values for the spectrum (i.e., if custom m/z values are needed for interpretation of the returned spectrum).This may be needed, e.g., in cases where a per-spectrum peak analysis is performed and the peaks for each spectrum appear at different m/z values.
-
classmethod
v_qspectrum_viewer_options
(analysis_object)¶ Get a list of strings describing the different default viewer options for the analysis for qspectrum. The default implementation tries to take care of handling the spectra retrieval for all the depencies but can naturally not decide how the qspectrum should be handled by a derived class. However, this implementation is often called at the end of custom implementations to also allow access to data from other dependencies.
Parameters: analysis_object – The omsi_file_analysis object for which slicing should be performed. For most cases this is not needed here as the support for slice operations is usually a static decission based on the class type, however, in some cases additional checks may be needed (e.g., ensure that the required data is available). Returns: List of strings indicating the different available viewer options. The list should be empty if the analysis does not support qspectrum requests (i.e., v_qspectrum(...) is not available).
-
classmethod
-
class
omsi.analysis.multivariate_stats.
omsi_kmeans
(name_key='undefined')¶ Bases:
omsi.analysis.base.analysis_base
Class defining a basic nmf analysis for a 2D MSI data file or slice of the data
Initalize the basic data members
-
execute_analysis
()¶ Execute the kmeans clustering for the given msidata
-
omsi_nmf
Module¶
Module for performing non-negative matrix factorization (NMF) for MSI data.
-
class
omsi.analysis.multivariate_stats.omsi_nmf.
omsi_nmf
(name_key='undefined')¶ Bases:
omsi.analysis.base.analysis_base
Class defining a basic nmf analysis.
The function has primarily been tested we MSI datasets but should support arbitrary n-D arrays (n>=2). The last dimension of the input array must be the spectrum dimnensions.
Initalize the basic data members
-
execute_analysis
()¶ Execute the nmf for the given msidata
-
classmethod
v_qmz
(analysis_object, qslice_viewer_option=0, qspectrum_viewer_option=0)¶ Implement support for qmz URL requests for the viewer
-
classmethod
v_qslice
(analysis_object, z, viewer_option=0)¶ Implement support for qslice URL requests for the viewer
-
classmethod
v_qslice_viewer_options
(analysis_object)¶ Define which viewer_options are supported for qspectrum URL’s
-
classmethod
v_qspectrum
(analysis_object, x, y, viewer_option=0)¶ Implement support for qspectrum URL requests for the viewer
-
classmethod
v_qspectrum_viewer_options
(analysis_object)¶ Define which viewer_options are supported for qspectrum URL’s
-
multivariate_stats.third_party Package¶
multivariate_stats.third_party
Package¶
Package containing shared third-party code modules included here to reduce the need for external dependencies when only small parts of external code are used.
nmf
Module¶
Copyright (c) 2005-2008 Chih-Jen Lin All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither name of copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
omsi.analysis.multivariate_stats.third_party.nmf.
nlssubprob
(V, W, Hinit, tol, maxiter)¶ H, grad: output solution and gradient iter: #iterations used V, W: constant matrices Hinit: initial solution tol: stopping tolerance maxiter: limit of iterations
-
omsi.analysis.multivariate_stats.third_party.nmf.
nmf
(V, Winit, Hinit, tol, timelimit, maxiter)¶ (W,H) = nmf(V,Winit,Hinit,tol,timelimit,maxiter) W,H: output solution Winit,Hinit: initial solution tol: tolerance for a relative stopping condition timelimit, maxiter: limit of time and iterations