The Labeling class is a container class for Labels. When created, the
Labeling only knows about the dataset object to which it is bound. This
dataset object may be a Dataset, View, PagedDataset or other class derived
from IDataset.
When labels are attatched to the underlying dataset, a unique ID is requested
from the dataset and that ID is used as a cookie. This allows for the
Labelings to uniquely look for and/or filter their labels in the dataset
Methods
|
|
|
|
__init__
|
__init__ (
self,
dataset,
name=None,
nolink=0,
)
|
|
__repr__
|
__repr__ ( self )
|
|
__str__
|
__str__ ( self )
|
|
addLabelToCol
|
addLabelToCol (
self,
label,
col,
)
Attatches a label to a particular column of the associated dataset.
|
|
addLabelToCols
|
addLabelToCols (
self,
label,
colList,
)
Attatches the label to all of the columns in colList. Uses addLabelToCol()
underneath.
|
|
addLabelToKey
|
addLabelToKey (
self,
label,
key,
)
Attatches a label to a particular key of the associated dataset.
|
|
addLabelToKeys
|
addLabelToKeys (
self,
label,
keyList,
)
Attatches the label to all of the keys in keyList. Uses addLabelToCol()
underneath.
|
|
addLabelToRow
|
addLabelToRow (
self,
label,
row,
)
Attatches a label to a particular row of the associated dataset.
|
|
addLabelToRows
|
addLabelToRows (
self,
label,
rowList,
)
Attatches the label to all of the rows in rowList. Uses addLabelToRow()
underneath.
|
|
addLabelsToCol
|
addLabelsToCol (
self,
labels,
col,
)
Attatches a set of labels to a particular column.
|
|
addLabelsToCols
|
addLabelsToCols (
self,
labels,
cols,
)
Attatches a list of label sets to a set of columns.
|
|
addLabelsToKey
|
addLabelsToKey (
self,
labels,
key,
)
Attatches a set of labels to a particular key.
|
|
addLabelsToKeys
|
addLabelsToKeys (
self,
labels,
keys,
)
Attatches a list of label sets to a set of keys.
|
|
addLabelsToRow
|
addLabelsToRow (
self,
labels,
row,
)
Attatches a set of labels to a particular row.
|
|
addLabelsToRows
|
addLabelsToRows (
self,
labels,
rows,
)
Attatches a list of label sets to a set of rows.
|
|
detatch
|
detatch ( self )
Remove the labeling from the dataset.
This will remove all the data relevant to this labeling from the dataset
and all references to the dataset. This method is not generally useful
to a client program. Use IDataset.removeLabeling() to remove a labeling
from a dataset object.
|
|
getAllColLabels
|
getAllColLabels ( self )
Returns a list of lists of the labels for all the columns.
|
|
getAllKeyLabels
|
getAllKeyLabels ( self )
Returns a list of lists of the labels for all the keys.
|
|
getAllRowLabels
|
getAllRowLabels ( self )
Returns a list of lists of the labels for all the rows.
|
|
getColsByLabel
|
getColsByLabel ( self, label )
Returns all the columns which are marked by the label given.
|
|
getDataset
|
getDataset ( self )
Returns the dataset instance to which this labeling is bound.
|
|
getKeysByLabel
|
getKeysByLabel ( self, label )
Returns a list of keys marked by the specified label.
|
|
getLabelByCol
|
getLabelByCol (
self,
col,
n=0,
)
Gets the Nth label from a given column. Returns None if a label does
not exist. By default this will return the first label in the list.
|
|
getLabelByCols
|
getLabelByCols (
self,
cols=None,
n=0,
)
|
|
getLabelByKey
|
getLabelByKey (
self,
key,
n=0,
)
Gets the Nth label from a given key. Returns None if a label does
not exist. By default this will return the first label in the list.
|
|
getLabelByKeys
|
getLabelByKeys (
self,
keys=None,
n=0,
)
|
|
getLabelByRow
|
getLabelByRow (
self,
row,
n=0,
)
Gets the Nth label from a given row. Returns None if a label does
not exist.
|
|
getLabelByRows
|
getLabelByRows (
self,
rows=None,
n=0,
)
|
|
getLabels
|
getLabels ( self )
Returns a list of all the labels this labeling has knowledge about.
|
|
getLabelsByCol
|
getLabelsByCol ( self, col )
Returns a list of all labels associated with a particular column
|
|
getLabelsByCols
|
getLabelsByCols ( self, cols )
Returns a list of lists of all labels from a set of columns.
|
|
getLabelsByKey
|
getLabelsByKey ( self, key )
Returns a list of labels for a specific key. The labels returned are
only those created by this Labeling.
|
|
getLabelsByKeys
|
getLabelsByKeys ( self, keys )
Returns a list of lists of all labels from a set of keys.
|
|
getLabelsByRow
|
getLabelsByRow ( self, row )
Returns a list of all labels associated with a particular row.
|
|
getLabelsByRows
|
getLabelsByRows ( self, rows )
Returns a list of lists of all labels from a set of rows.
|
|
getName
|
getName ( self )
Returns the name of this labeling.
Names are indentifierd bestowed upon the labeling when it is created or at
a later point via the setName() method. The name may be None.
|
|
getRowsByLabel
|
getRowsByLabel ( self, label )
Returns all the rows which are marked by the label.
|
|
labelCols
|
labelCols ( self, obj )
Labels all columns with the contents of the the object.
Performs identically to labelRows(), except on columns.
|
|
labelFrom
|
labelFrom (
self,
labeling,
name=None,
)
Creates and returns a labeling for the dataset based on the labeling
of a different view or dataset. If the given labeling is already attatched to the dataset, no action is
performed and None is returned. In the case where the Labeling is
attatched to a different dataset, the common datapoints will be labeled
with the same labels that Labeling contains.
Example usage:
view1 = dataset.subsetRows([0,1,2,3,4])
view2 = dataset.subsetRows([2,3,4,5,6])
labeling1 = Labeling(view1)
labeling1.addLabelToRows("top5", range(view1.getNumRows()))
//
// Now use labeling1 to label view2
//
labeling2 = Labeling(view2)
labeling2.labelFrom(labeling1)
//
// The common datapoints (2,3,4) are now labeled with "top5" and may
// be retieved
//
num = len(labeling2.getRowsByLabel("top5"))
print str(num) + " of my top 5 genes are in this dataset"
|
|
labelRows
|
labelRows ( self, obj )
Labels all the rows with the contents of the object.
labelRows() casts the object to a list of hashable python objects and then
labels the rows of the dataset with the resulting objects. See the
_castLabels() method for details on how different objects are cast.
|
|
removeAll
|
removeAll ( self )
Removes all the labels in the labeling and unmarks every key in the dataset
which is marked by this Labeling. Labels attatched to keys by other
labelings are not affected.
|
|
removeLabel
|
removeLabel ( self, label )
Removes a label and unmarks all the keys in the dataset associated with
the label.
|
|
removeLabelFromCol
|
removeLabelFromCol (
self,
label,
col,
)
Remove a single label from a given column.
|
|
removeLabelFromKey
|
removeLabelFromKey (
self,
label,
key,
)
Remove a single label from a single key.
|
|
removeLabelFromRow
|
removeLabelFromRow (
self,
label,
row,
)
Remove a single label from a given row.
|
|
removeLabelsFromCol
|
removeLabelsFromCol ( self, col )
removeLabelsFromCol(row)
Removes all the labels in this Labeling from a specified column of the
dataset.
|
|
removeLabelsFromKey
|
removeLabelsFromKey ( self, key )
Removes all the labels in this Labeling from a specified key of the
dataset.
|
|
removeLabelsFromRow
|
removeLabelsFromRow ( self, row )
Removes all the labels in this Labeling from a specified row of the
dataset.
|
|
setName
|
setName ( self, name )
Sets the name for the labeling.
This method replaces the current LAbeling name with the one specified.
|
|
sortDatasetByLabel
|
sortDatasetByLabel ( self )
Row sorts a SortedView via labeling information.
This method only works if the labeling is attatched to a sorted view
(or derivative).
|
|
writeLabels
|
writeLabels (
self,
stream=sys.stdout,
delimiter="\t",
)
Prints out all row labels to the specified stream.
The labels will be written out in row order from smallest to largest.
If there is more than one label on a line, the labels are separated by
the specified delimiter.
|