Scoring Methods
nplinker.scoring
¶
MetcalfScoring
¶
Bases: ScoringBase
Metcalf scoring method.
Attributes:
-
name–The name of this scoring method, set to a fixed value
metcalf. -
npl(NPLinker | None) –The NPLinker object.
-
CACHE(str) –The name of the cache file to use for storing the MetcalfScoring.
-
presence_gcf_strain(DataFrame) –A DataFrame to store presence of gcfs with respect to strains. The index of the DataFrame are the GCF objects and the columns are Strain objects. The values are 1 where the gcf occurs in the strain, 0 otherwise.
-
presence_spec_strain(DataFrame) –A DataFrame to store presence of spectra with respect to strains. The index of the DataFrame are the Spectrum objects and the columns are Strain objects. The values are 1 where the spectrum occurs in the strain, 0 otherwise.
-
presence_mf_strain(DataFrame) –A DataFrame to store presence of molecular families with respect to strains. The index of the DataFrame are the MolecularFamily objects and the columns are Strain objects. The values are 1 where the molecular family occurs in the strain, 0 otherwise.
-
raw_score_spec_gcf(DataFrame) –A DataFrame to store the raw Metcalf scores for spectrum-gcf links. The columns are "spec", "gcf" and "score":
- The "spec" and "gcf" columns contain the Spectrum and GCF objects respectively,
- The "score" column contains the raw Metcalf scores.
-
raw_score_mf_gcf(DataFrame) –A DataFrame to store the raw Metcalf scores for molecular family-gcf links. The columns are "mf", "gcf" and "score":
- The "mf" and "gcf" columns contain the MolecularFamily and GCF objects respectively,
- the "score" column contains the raw Metcalf scores.
-
metcalf_mean(ndarray | None) –A numpy array to store the mean value used for standardising Metcalf scores. The array has shape (n_strains+1, n_strains+1), where n_strains is the number of strains.
-
metcalf_std(ndarray | None) –A numpy array to store the standard deviation value used for standardising Metcalf scores. The array has shape (n_strains+1, n_strains+1), where n_strains is the number of strains.
metcalf_weights
class-attribute
instance-attribute
¶
presence_gcf_strain
class-attribute
instance-attribute
¶
presence_spec_strain
class-attribute
instance-attribute
¶
raw_score_spec_gcf
class-attribute
instance-attribute
¶
raw_score_mf_gcf
class-attribute
instance-attribute
¶
setup
classmethod
¶
setup(npl: NPLinker) -> None
Setup the MetcalfScoring object.
This method is only called once to setup the MetcalfScoring object.
Parameters:
-
npl(NPLinker) –The NPLinker object.
Source code in src/nplinker/scoring/metcalf_scoring.py
get_links
¶
get_links(
*objects: MolecularFamily, **parameters: Any
) -> LinkGraph
Get links for the given objects.
Parameters:
-
objects–The objects to get links for. All objects must be of the same type, i.e.
GCF,SpectrumorMolecularFamilytype. If no objects are provided, all detected objects (npl.gcfs) will be used. -
parameters–The scoring parameters to use for the links. The parameters are:
cutoff: The minimum score to consider a link (≥cutoff). Default is 0.standardised: Whether to use standardised scores. Default is False.
Returns:
-
–
The
LinkGraphobject containing the links involving the input objects with the Metcalf scores.
Raises:
-
TypeError–If the input objects are not of the same type or the object type is invalid.