11 Commits

Author SHA1 Message Date
ded2faaf2c Removed the title of the plot from the canvas, as it is now shown above
the canvas as well. Updated the matplotlib axis limits to reflect this and
allow more space for the plot.
2006-10-12 14:56:53 +00:00
92a8a819e8 Plots restore current selection on set_frozen(False) 2006-10-12 12:58:48 +00:00
3a62580125 Plots now show names outside the canvas. 2006-10-12 12:46:34 +00:00
31527e51fd Added freeze icon. 2006-10-12 12:20:19 +00:00
28cab35cd5 The toolbar functionality is almost back to normal. 2006-10-12 11:44:49 +00:00
f435b37046 Rectangle modes work, pan does not. 2006-10-11 12:05:13 +00:00
a6571d8c6b Cleaned up toolbar code, lots of work still to be done.
Does not work.
2006-10-10 21:15:13 +00:00
0ed180d6ab move icon
AM   move.png
2006-10-10 21:09:12 +00:00
5e2d1a4ae6 toolbar icons 2006-10-10 15:36:19 +00:00
502cd22dc8 2006-10-10 15:23:35 +00:00
958c6dbfdf testing new toolbar 2006-10-10 15:19:12 +00:00
139 changed files with 4265 additions and 51759 deletions

61
LICENSE
View File

@ -276,3 +276,64 @@ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -1,30 +0,0 @@
PREFIX=M4_PREFIX
BIN_DIR=M4_BINDIR
DATA_DIR=M4_DATADIR
PY_DIR=M4_PYDIR
DOC_DIR=M4_DOCDIR
SCRIPTS_DIR=${DATA_DIR}/laydi/scripts/
install: install_laydi install_doc
install_laydi:
## Install binary files
install -m 755 -D bin/laydi ${BIN_DIR}/laydi
install -m 755 -D bin/dataset ${BIN_DIR}/dataset
## Install library files
find laydi/ -type f -name '*.py' -exec install -m 644 -D {} ${PY_DIR}/{} \;
find laydi/ -type f -name '*.glade' -exec install -m 644 -D {} ${PY_DIR}/{} \;
## Install icons
find icons/ -type f -name '*.png' -exec install -m 644 -D {} ${DATA_DIR}/{} \;
install_scripts:
find scripts/ -type f -exec install -D {} ${SCRIPTS_DIR}/{} \;
install_doc:
DOC_DIR=${DOC_DIR}/ make -C doc install
install -m 644 README ${DOC_DIR}/
install -m 644 LICENSE ${DOC_DIR}/

View File

@ -1,10 +0,0 @@
Package: laydi
Type: Package
Title: Interface to Laydi
Version: 0.1.0
Date: 2011-03-05
Author: Einar Ryeng <einarr@pvv.ntnu.no>
Maintainer: Einar Ryeng <einarr@pvv.ntnu.no>
Description: R interface to Laydi
License: LGPL
LazyLoad: yes

View File

@ -1,61 +0,0 @@
write.ftsv <- function(data, con, name="unnamed_dataset", rowdim="rows", coldim="cols") {
# If con is a file name, open it
opened.here = FALSE
if (is.character(con)){
con = file(con, "w")
opened.here = TRUE
}
# Substitute all whitespace with underscores in identifiers
rows <- paste(gsub("\\s", "_", rownames(data)), collapse=" ")
cols <- paste(gsub("\\s", "_", colnames(data)), collapse=" ")
# Write header
writeLines(c("# type: dataset",
paste("# dimension:", rowdim, rows, collapse=' '),
paste("# dimension:", coldim, cols, collapse=' '),
paste("# name:", name, collapse=' '),
""),
con=con)
# Write matrix
write.table(data, file=con, col.names=FALSE, row.names=FALSE, sep="\t")
# If con was a string, close file now
if (opened.here)
close(con)
}
write.laydi.selection <- function(data, con) {
# If con is a file name, open it
opened.here = FALSE
if (is.character(con)){
con = file(con, "w")
opened.here = TRUE
}
writeLines(gsub("\\s", "_", data), con=con)
# If con was a string, close file now
if (opened.here)
close(con)
}
read.laydi.selection <- function(con) {
# If con is a file name, open it
opened.here = FALSE
if (is.character(con)){
con = file(con)
opened.here = TRUE
}
ids <- readLines(con=con, encoding="UTF-8")
# If con was a string, close file now
if (opened.here)
close(con)
ids
}

View File

@ -1,38 +0,0 @@
\name{laydi-package}
\alias{laydi-package}
\alias{laydi}
\docType{package}
\title{Interface to Laydi}
\description{
Interface to Laydi files and projects. Allows writing R matrices to laydi data files.
}
\details{
\tabular{ll}{
Package: \tab laydi\cr
Type: \tab Package\cr
Version: \tab 0.1.0\cr
Date: \tab 2011-03-05\cr
License: \tab LGPL\cr
LazyLoad: \tab yes\cr
}
library(laydi)
write.ftsv(matrix, file, ...)
write.laydi.selection(idlist, file)
}
\author{
Einar Ryeng <einarr@pvv.org>\cr
Arnar Flatberg <arnar.flatberg@gmail.com>
Maintainer: Einar Ryeng <einarr@pvv.org>
}
\references{
}
\keyword{ package }
\seealso{
% ~~ Optional links to other man pages, e.g. ~~
% ~~ \code{\link[<pkg>:<pkg>-package]{<pkg>}} ~~
}
\examples{
}

View File

@ -1,53 +0,0 @@
\name{read.laydi.selection}
\alias{read.laydi.selection}
\title{read.laydi.selection}
\description{
Reads a list of identifiers from a file.
}
\usage{
read.laydi.selection(con)
}
\arguments{
\item{con}{
Connection (or file name) to read from. If con is a character string, it
will be treated as a file name, and the file will be opened, read and
closed. If con is an open connection (file descriptor), the file will
remain open.
}
}
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
%% ~Describe the value returned
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
Laydi and the laydi R package are not published in the litterature. Source code
can be found at http://dev.pvv.ntnu.no/projects/laydi
}
\author{
Einar Ryeng
}
\note{
%% ~~further notes~~
}
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
read.laydi.selection("/tmp/selected_samples")
}
\keyword{ IO }
\keyword{ file }

View File

@ -1,74 +0,0 @@
\name{write.ftsv}
\alias{write.ftsv}
\title{write.ftsv}
\description{
Writes a matrix to a ftsv (laydi dataset) file. The matrix must have rownames
and colnames. Rownames and colnames must be unique, and whitespace characters
will be replaced with underscores.
}
\usage{
write.ftsv(data, con, name = "unnamed_dataset", rowdim = "rows", coldim = "cols")
}
\arguments{
\item{data}{
A data matrix. All items in rownames(data) and colnames(data) must be
unique, and all whitespace characters will be replaced wity underscores in
the output. (Laydi requires unique identifiers along a dimension, and does
not allow identifiers to contain spaces.)
}
\item{con}{
Connection (or file name) to write the data to. If con is a character
string, it will be treated as a file name, and a file by that name will be
created, written to and closed. If con is an open connection (file descriptor),
the file will remain open.
}
\item{name}{
Datasets in laydi have a name.
}
\item{rowdim}{
Laydi names all dimensions of matrices. rowdim is the dimension
name for rows in the the file. E.g. "samples", if rows denotes samples.
}
\item{coldim}{
Laydi names all dimensions of matrices. coldim is the dimension
name for columns in the the file. E.g. "gene-ids" if columns represent
genes.
}
}
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
%% ~Describe the value returned
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
Laydi and this R package are not published in the litterature. Source code can be found at
http://dev.pvv.ntnu.no/projects/laydi
}
\author{
Einar Ryeng
}
\note{
%% ~~further notes~~
}
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
library(datasets)
write.ftsv(randu, "/tmp/randu.ftsv")
}
\keyword{ IO }
\keyword{ file }

View File

@ -1,61 +0,0 @@
\name{write.laydi.selection}
\alias{write.laydi.selection}
\title{write.laydi.selection}
\description{
Writes a Laydi selection file from a list of identifiers. Identifiers are
written one per line, with all whitespace characters substituted with
underscores.
}
\usage{
write.laydi.selection(data, con)
}
\arguments{
\item{data}{
A list of identifiers. All whitespace characters will be replaced wity
underscores in the output. (Laydi requires unique identifiers along a
dimension, and does not allow identifiers to contain spaces.) This method
does not ensure that identifiers are unique.
}
\item{con}{
Connection (or file name) to write the data to. If con is a character
string, it will be treated as a file name, and a file by that name will be
created, written to and closed. If con is an open connection (file descriptor),
the file will remain open.
}
}
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
%% ~Describe the value returned
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
Laydi and the laydi R package are not published in the litterature. Source code
can be found at http://dev.pvv.ntnu.no/projects/laydi
}
\author{
Einar Ryeng
}
\note{
%% ~~further notes~~
}
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
write.laydi.selection(c("sample1", "sample2", "sample3"), "/tmp/selected_samples")
}
\keyword{ IO }
\keyword{ file }

27
README Normal file
View File

@ -0,0 +1,27 @@
Fluents Data Analysis Software
LICENSE
-------
Fluents is relased under the terms of the GNU GPL, included in the LICENSE file
in this directory.
DOCUMENTATION
-------------
The primary and canonical source of documentation is the source code. If a
keyboard shortcut is listed on the wiki but it does not work in the program,
the program is right, and the wiki is wrong.
That said, the next best place to look for documentation is the project wiki,
located at https://dev.pvv.ntnu.no/projects/fluent/help
BUILDING
--------
Fluents is a python program, and as such, python will build compiled versions
of each .py file as it loads them. You do not need to explicitly compile the
program.
TODO
----
The current TODO list can be found on
https://dev.pvv.ntnu.no/projects/fluent/report/1

View File

@ -1,57 +0,0 @@
![](./wiki/graphics/project_icon.png)
# Laydi
## Look At Your Data Interactively
Laydi is an acronym for look at your data interactively, which is what the program is aimed at. It is a lightweight data analysis program for bilinear modeling (PCA and PLS) with a strong focus on interactive use. Laydi is released under the GNU GPL and the latest development snapshot can be downloaded from https://git.pvv.ntnu.no/Projects/laydi.git
![](./wiki/graphics/screenshot-00.png)
## Features
- Principal Component Analysis (PCA)
- Partial Least Squares Regression (PLS)
- L-shaped PLS regression (L-PLS)
- Easy mapping of variables between plots, selections in one plot propagates to other plots.
## Nonfeatures
- Does not import arbitrary files. Files must be prepared in a (simple) file format prior to import.
- Saving and loading of projects is not implemented. (Datasets can be saved and loaded, though, and plots can be exported)
- Not very stable
## Installation requirements
Laydi currently requires the following extra packages, available from apt on Debian and Ubuntu.
- python2.4 or python2.5
- python-glade2
- python-gnome2
- python-gtk2
- python-matplotlib
- python-scipy
- python-numpy
Partially needed
- python-networkx
- python-pygraphviz
## Download laydi
Laydi is not debianized. To download it, use the clone the git repo.
```console
git clone https://git.pvv.ntnu.no/Projects/laydi.git
```
## User documentation
- [Frequently Asked Questions](./wiki/faq.md)
- [Laydi help](./wiki/help.md) (the same as available through the help menu in the application.)
- [Terminology](./wiki/Terminology.md)
## Developer documentation
- [Developer tips and tricks](./wiki/development/hints.md)

View File

@ -1,41 +0,0 @@
Laydi Data Analysis Software
LICENSE
-------
Laydi is relased under the terms of the GNU GPL, included in the LICENSE file
in this directory.
DOCUMENTATION
-------------
The primary and canonical source of documentation is the source code. If a
keyboard shortcut is listed on the wiki but it does not work in the program,
the program is right, and the wiki is wrong.
That said, the next best place to look for documentation is the project wiki,
located at https://dev.pvv.ntnu.no/projects/laydi/help
Class documentation is in HTML form in the doc/ directory.
BUILDING
--------
Laydi is a python program, and as such, python will build compiled versions
of each .py file as it loads them. You do not need to explicitly compile the
program.
If you have just checked out the program to a directory named laydi, e.g. with
the command:
svn co https://dev.pvv.org/svn/laydi/trunk laydi
you can run it by typing:
cd laydi
./configure --prefix=`pwd`/build
make
./run-laydi
TODO
----
The current TODO list can be found on
https://dev.pvv.ntnu.no/projects/laydi/report/1

View File

@ -1,116 +0,0 @@
#!/usr/bin/python
import os,sys
from laydi import dataset
import cfgparse, optparse
import re
PROGRAM_NAME = 'dataset'
VERSION = '0.1.0'
def read_dataset_header(input):
name = ""
type = ""
dimensions = []
kv_re = re.compile('^\s*#\s*(\w+)\s*:(.*)$')
lines = []
line = input.readline()
while line.startswith('#'):
lines.append(line)
line = input.readline()
for line in lines:
match = kv_re.match(line)
if not match:
continue
k, v = match.groups()
k = k.strip()
if k == 'name':
name = v
elif k == 'type':
type = v
elif k == 'dimension':
values = v.split()
dimensions.append((values[0], values[1:]))
return (name, type, dimensions)
def show_info(input):
name, type, dimensions = read_dataset_header(input)
print "Name: %s" % name
print "Type: %s" % type
print "Dimensions:",
for i, dim in enumerate(dimensions):
dimname = dim[0]
length = len(dim[1])
print "%s(%i)" % (dimname, length),
if i < len(dimensions)-1:
print "x",
print
def list_dimension_ids(input, dimname):
name, type, dimensions = read_dataset_header(input)
for i, dim in enumerate(dimensions):
name, ids = dim
if name == dimname:
for id in ids:
print id
def parse_options():
conf_files = ['/etc/laydirc',
os.path.join(os.environ['HOME'], '.laydi')]
cp = cfgparse.ConfigParser()
op = optparse.OptionParser()
op.add_option('-c', '--csv',
action='store_true', default=False,
help='Export as CSV file.')
op.add_option('-d', '--dimension',
action='store', default=None,
help='Get all identifiers along a dimension.')
op.add_option('-i', '--info',
action='store_true', default=False,
help='Show dataset information.')
op.add_option('-l', '--longinfo',
action='store_true', default=False,
help='Display more information than -i.')
op.add_option('-o', '--output-file',
action='store_true', default=False,
help='Send output to file instead of stdout.')
op.add_option('-t', '--transpose',
action='store_true', default=False,
help='Transpose dataset.')
op.add_option('-y', '--change-type',
action='store_true', default=False,
help='Set new dataset type.')
for cf in conf_files:
if os.path.isfile(cf):
cp.add_file(cf)
return cp.parse(op)
if __name__ == '__main__':
options, params = parse_options()
input = sys.stdin
output = sys.stdout
if options.info:
show_info(input)
sys.exit(0)
elif options.dimension != None:
list_dimension_ids(input, options.dimension)

View File

@ -1,50 +0,0 @@
#!/usr/bin/python
import sys
from laydi import dataset
from getopt import getopt
def read_options():
short_opts = ""
long_opts = []
options, params = getopt(sys.argv[1:], short_opts, long_opts)
return params
def write_csv(fd, ds):
rowdim, coldim = ds.get_dim_name()
rowids = ds.get_identifiers(rowdim, sorted=True)
colids = ds.get_identifiers(coldim, sorted=True)
x = ds.asarray()
## Print ID row
print >> fd, rowdim,
for id in colids:
print >> fd, id,
print >> fd
## Print column IDs and data
for i, row in enumerate(rowids):
print >> fd, row,
for j in range(len(colids)):
print >> fd, x[i,j],
print >> fd
if __name__ == "__main__":
params = read_options()
input_fn = params[0]
if len(params) == 2:
output_fn = params[1]
else:
name, ext = input_fn.rsplit('.', 1)
output_fn = name + '.csv'
ds = dataset.read_ftsv(input_fn)
output_fd = open(output_fn, 'w')
write_csv(output_fd, ds)
output_fd.close()

145
bin/laydi
View File

@ -1,145 +0,0 @@
#!/usr/bin/python
from getopt import getopt
import os
import sys
from laydi import laydi, project, projectview, workflow, main
#import workflows
from laydi import cfgparse
import optparse
PROGRAM_NAME = 'laydi'
VERSION = '0.1.0'
def list_workflows():
print 'laydi %s' % VERSION
print
print 'Available workflows:'
wfs = workflow.workflow_list()
for wf in wfs:
print ' %s (%s)' % (wf.ident, wf.name)
print
def generate_config():
fn = os.path.join(os.environ['HOME'], '.laydi')
if not os.path.exists(fn):
fd = open(fn, 'w')
print >> fd, "home = %s" % os.environ['HOME']
print >> fd, "datadir = %%(home)s/laydi/datasets"
print >> fd, "workflowdir = %%(home)s/laydi/workflows"
fd.close()
laydidir = os.path.join(os.environ['HOME'], 'laydi')
if not os.path.exists(laydidir):
os.mkdir(laydidir, 0755)
datadir = os.path.join(os.environ['HOME'], 'laydi/datasets')
if not os.path.exists(datadir):
os.mkdir(datadir, 0755)
workflowdir = os.path.join(os.environ['HOME'], 'laydi/workflows')
if not os.path.exists(workflowdir):
os.mkdir(workflowdir, 0755)
def parse_options():
conf_files = ['/etc/laydirc',
os.path.join(os.environ['HOME'], '.laydi')]
cp = cfgparse.ConfigParser()
cp.add_option('home', type='string',
default=os.environ['HOME'])
cp.add_option('datadir', type='string',
default=os.environ['HOME'])
cp.add_option('workflowdir', type='string',
default='workflows')
cp.parse()
op = optparse.OptionParser()
op.add_option('-l', '--list-workflows',
action='store_true',
default=False,
help='List available workflows.')
op.add_option('-w', '--workflow',
default='default',
help='Start with selected workflow')
op.add_option('-c', '--generate-config',
action='store_true',
help='Generate configuration file ~/.laydi if it does not exist.')
op.add_option('-n', '--new-project',
action='store_true',
help='Create new project directory.')
for cf in conf_files:
if os.path.isfile(cf):
cp.add_file(cf)
options, params = cp.parse(op)
if len(params) != 1:
print "error: project directory must be specified."
print "notice: to create a new project use -n /path/to/project"
sys.exit(1)
return options, params
if __name__ == '__main__':
import gtk
import gnome
gnome.program_init(PROGRAM_NAME, VERSION)
options, params = parse_options()
## Workflow setup
main.options = options
for dir in main.options.workflowdir.split(';'):
if dir.strip() != "" and os.path.exists(dir):
sys.path.append(dir)
if options.list_workflows:
list_workflows()
sys.exit(0)
if options.generate_config:
generate_config()
sys.exit(0)
selected_wf = workflow.find_workflow(options.workflow)
if selected_wf == None: selected_wf = workflow.EmptyWorkflow
# workflow_list = workflow.workflow_list()
# for wf in workflow_list:
# if wf.ident == options.workflow:
# selected_wf = wf
main.set_workflow(selected_wf())
main.set_options(options)
app = laydi.LaydiApp()
## Project setup
prjroot = params[0]
if not project.is_project_directory(prjroot):
if options.new_project:
project.make_project_directory(prjroot)
else:
print "error: project directory not found: %s" % prjroot
print "notice: use the -n option to make a new project"
sys.exit(2)
proj = project.Project(prjroot)
main.project = proj
main.set_application(app)
main.set_projectview(projectview.ProjectView(proj))
app.set_projectview(main.projectview)
app.show()
gtk.main()

View File

@ -1,37 +0,0 @@
#!/usr/bin/python
import sys
from getopt import getopt
def show_help():
print "mat2ftsv - Matlab matrix to laydi dataset converter."
print
print "Usage: mat2ftsv <mat-file> [<matfile> ...]"
print
print "Description: For each mat file given as input, a ftsv file"
print " will be created with the same name, but suffixed with.ftsv"
print " in addition to .mat or any other suffix already on the"
print " file name."
options, params = getopt(sys.argv[1:], 'h', ['help'])
for opt, val in options:
if opt in ['-h', '--help']:
show_help()
sys.exit(0)
if len(params) == 0:
show_help()
sys.exit(0)
from scipy import io
from numpy import ndarray
from laydi import dataset
fn_in = params[0]
data = io.loadmat(fn_in)
for key, value in data.items():
if isinstance(value, ndarray):
ds = dataset.Dataset(value, name=key)
dataset.write_ftsv(fn_in + '.ftsv', ds)

View File

@ -1,100 +0,0 @@
#!/usr/bin/env python
import numpy
import os.path
import sys
from laydi import dataset
from getopt import getopt
dimension = 'dim_doe'
output_fn = '-'
ds_name = None
category = False
sparse = False
def print_help():
print
print 'options:'
print ' -h, --help Show this help text.'
print ' -c, --category Make category dataset'
print ' -d, --dimension=DIM Make output in dimension DIM'
print ' -n, --name=NAME Set name of output dataset'
print ' -o, --output=FILE Save output dataset in FILE'
print ' -s, --sparse Save output in sparse format'
print
def parse_options():
global ds_name
global output_fn
short_opts = 'cd:hn:o:'
long_opts = ['help', 'category', 'dimension', 'name', 'output', 'sparse']
options, params = getopt(sys.argv[1:], short_opts, long_opts)
for opt, val in options:
if opt in ['-h', '--help']:
print_help()
sys.exit(0)
elif opt in ['-c', '--category']:
global category
category = True
elif opt in ['-d', '--dimension']:
global dimension
dimension = val
elif opt in ['-n', '--name']:
ds_name = val
elif opt in ['-o', '--output']:
output_fn = val
elif opt in ['-s', '--sparse']:
global sparse
sparse = True
if ds_name == None:
if output_fn != None:
ds_name = output_fn
else:
ds_name = 'txt2ftsv'
if len(params) == 0:
print_help()
sys.exit(1)
return params
def read_file(fd):
lines = fd.readlines()
return [l.strip() for l in lines if l.strip() != '']
def build_dataset(dimension, id_lists, filenames):
all_ids = list(reduce(set.union, [set(x) for x in id_lists]))
x = numpy.zeros((len(all_ids), len(id_lists)), 'b')
for i, idl in enumerate(id_lists):
for id in idl:
x[all_ids.index(id),i] = True
if category:
ds = dataset.CategoryDataset(x, [(dimension, all_ids), ('files', filenames)], name=ds_name)
else:
ds = dataset.Dataset(x, [(dimension, all_ids), ('files', filenames)], name=ds_name)
return ds
if __name__ == '__main__':
id_lists = []
filenames = parse_options()
for fn in filenames:
if os.path.exists(fn):
fd = open(fn)
id_lists.append(read_file(fd))
fd.close()
elif fn == '-':
id_lists.append(read_file(sys.stdin))
ds = build_dataset(dimension, id_lists, filenames)
if output_fn == '-':
dataset.write_ftsv(sys.stdout, ds, sp_format=sparse)
else:
dataset.write_ftsv(output_fn, ds, sp_format=sparse)

38
configure vendored
View File

@ -1,38 +0,0 @@
#!/bin/bash
TEMP=`getopt -o "" --long prefix:,bindir:,datadir:,pydir:,root: \
-n 'configure' -- "$@"`
eval set -- "$TEMP"
while true ; do
case "$1" in
--prefix) PREFIX=$2 ; shift 2 ;;
--bindir) BINDIR=$2 ; shift 2 ;;
--datadir) DATADIR=$2 ; shift 2 ;;
--pydir) PYDIR=$2 ; shift 2 ;;
--root) ROOT=$2 ; shift 2 ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
#if [[ $PREFIX == "" ]] ; then PREFIX=/usr/local ; fi
if [[ $BINDIR == "" ]] ; then BINDIR=$PREFIX/bin ; fi
if [[ $DATADIR == "" ]] ; then DATADIR=$PREFIX/share/laydi ; fi
if [[ $DOCDIR == "" ]] ; then DOCDIR=$PREFIX/share/doc/laydi; fi
if [[ $PYDIR == "" ]] ; then PYDIR=$PREFIX/share/pyshared/laydi; fi
m4 -D M4_PREFIX=$ROOT/$PREFIX -D M4_BINDIR=$ROOT/$BINDIR \
-D M4_DATADIR=$ROOT/$DATADIR -D M4_DOCDIR=$ROOT/$DOCDIR \
-D M4_PYDIR=$ROOT/$PYDIR Makefile.m4 > Makefile
m4 -D M4_PREFIX=$ROOT/$PREFIX -D M4_BINDIR=$ROOT/$BINDIR \
-D M4_DATADIR=$ROOT/$DATADIR -D M4_DOCDIR=$ROOT/$DOCDIR \
-D M4_PYDIR=$ROOT/$PYDIR doc/Makefile.m4 > doc/Makefile
m4 -D M4_PREFIX=$PREFIX -D M4_BINDIR=$BINDIR \
-D M4_DATADIR=$DATADIR -D M4_DOCDIR=$DOCDIR \
-D M4_PYDIR=$PYDIR laydi/paths.py.m4 > laydi/paths.py

6
debian/changelog vendored
View File

@ -1,6 +0,0 @@
laydi (0.1.0) unstable; urgency=low
* Initial packaging
-- Einar Ryeng <einarr@pvv.org> Tue, 11 Dec 2007 16:12:59 +0100

1
debian/compat vendored
View File

@ -1 +0,0 @@
5

22
debian/control vendored
View File

@ -1,22 +0,0 @@
Source: laydi
Section: science
Priority: optional
Maintainer: Einar Ryeng <einarr@pvv.org>
Build-Depends: debhelper (>= 5.0.37.2), python-dateutil, python-all-dev (>= 2.3.5-7), python-central (>= 0.5), python-epydoc, python-setuptools (>=0.6b3-1)
Standards-Version: 3.7.2
Package: laydi
Architecture: any
Depends: ${python:Depends}, python-numpy (>= 1:1.0.1), python-dev
Provides: ${python:Provides}
Description: Python library of bilinear modeling algorithms.
Bilinear modeling algorithms.
Package: laydi-doc
Architecture: all
Enhances: laydi
Description: Laydi API documentation.
Bilinear modeling algorithms.
.
This package contains documentation for Laydi

32
debian/copyright vendored
View File

@ -1,32 +0,0 @@
This package was debianized by Einar Ryeng <einarr@pvv.org> on
2007-09-11.
It was downloaded from https://dev.pvv.org/projects/laydi/downloads
Upstream Author: Arnar Flatberg <arnar.flatberg@gmail.com>
Copyright: Arnar Flatberg <arnar.flatberg@gmail.com>
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted under the terms of the BSD License.
THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
On Debian systems, the complete text of the BSD License can be
found in `/usr/share/common-licenses/BSD'.
The Debian packaging is (C) 2007, Einar Ryeng <einarr@pvv.org> and
is licensed under the GPL, see `/usr/share/common-licenses/GPL'.

1
debian/docs vendored
View File

@ -1 +0,0 @@
README

74
debian/rules vendored
View File

@ -1,74 +0,0 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
CFLAGS = -Wall -g
PYVERS=$(shell pyversions -vs)
configure: configure-stamp
configure-stamp:
dh_testdir
touch configure-stamp
build: $(PYVERS:%=build-python%)
build-python%:
dh_testdir
# python$* setup.py build
touch $@
clean:
# Add here commands to clean up after the build process.
-rm -r build
dh_clean
install: build $(PYVERS:%=install-python%)
install-python%:
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
./configure --root ${CURDIR}/debian/laydi --prefix /usr --pydir /usr/share/pyshared/
make install
# python$* setup.py install --root=$(CURDIR)/debian/laydi --install-data=/usr/share/laydi
# Remove all *.pyc files, created in the postinst
# find $(CURDIR)/debian/python-networkx -name "*.pyc" -exec rm {} ';'
# Build architecture-independent files here.
binary-indep: build install
make -C doc install
# mkdir -p $(CURDIR)/debian/laydi-doc/usr/share/doc/laydi-doc/html
# epydoc --html -o $(CURDIR)/debian/laydi-doc/usr/share/doc/laydi-doc/html laydi
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
# dh_install
dh_pysupport
dh_installman
dh_link
dh_strip
dh_compress
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

View File

@ -1,20 +0,0 @@
DOC_DIR=M4_DOCDIR
all: html
html:
@echo ----------------
@echo Generating epydoc html code documentation.
@echo See epydoc-html.log for epydoc log.
@echo ----------------
epydoc --html --inheritance listed -o html/ ../laydi 2> epydoc-html.log
install: html
find html/ -type f -exec install -m 644 -D '{}' ${DOC_DIR}/'{}' \;
clean:
-rm -rf html
-rm epydoc-html.log

View File

@ -1 +0,0 @@
Laydi project version 1

File diff suppressed because one or more lines are too long

View File

@ -1,215 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:ns="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="744.09448819"
height="1052.3622047"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.45.1"
sodipodi:docname="gui-overview.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
sodipodi:docbase="/home/einarr/src/laydi/doc"
inkscape:export-filename="/home/einarr/src/laydi/doc/gui-overview.png"
inkscape:export-xdpi="115"
inkscape:export-ydpi="115">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
<filter
inkscape:collect="always"
x="-0.010937911"
width="1.0218758"
y="-0.25053026"
height="1.5010605"
id="filter3210">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="2.1921397"
id="feGaussianBlur3212" />
</filter>
<filter
inkscape:collect="always"
id="filter3266">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="2.1921397"
id="feGaussianBlur3268" />
</filter>
<filter
inkscape:collect="always"
id="filter3306">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="2.4541485"
id="feGaussianBlur3308" />
</filter>
<filter
inkscape:collect="always"
id="filter3200">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="2.6375546"
id="feGaussianBlur3202" />
</filter>
<filter
inkscape:collect="always"
id="filter3240">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="2.5502183"
id="feGaussianBlur3242" />
</filter>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="472.59664"
inkscape:cy="577.79368"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1280"
inkscape:window-height="693"
inkscape:window-x="0"
inkscape:window-y="25">
<inkscape:grid
type="xygrid"
id="grid3171" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<ns:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</ns:Work>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#e3e6ff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2383"
width="500"
height="350"
x="140"
y="302.36218" />
<rect
style="fill:#eaf0ed;stroke:#000000;stroke-opacity:1;fill-opacity:1;filter:url(#filter3306)"
id="rect3163"
width="480"
height="80"
x="150"
y="562.36218" />
<rect
style="fill:#eaf0ed;stroke:#000000;stroke-opacity:1;fill-opacity:1;filter:url(#filter3200)"
id="rect3165"
width="90"
height="210"
x="150"
y="342.36218" />
<rect
style="fill:#eaf0ed;stroke:#000000;stroke-opacity:1;fill-opacity:1;filter:url(#filter3240)"
id="rect3167"
width="80"
height="210"
x="550"
y="342.36218" />
<rect
style="fill:#eaf0ed;stroke:#000000;stroke-opacity:1;fill-opacity:1;filter:url(#filter3266)"
id="rect3169"
width="290"
height="210"
x="250"
y="342.36218" />
<rect
style="fill:#eaf0ed;stroke:#000000;stroke-opacity:1;fill-opacity:1;filter:url(#filter3210)"
id="rect3173"
width="480"
height="20"
x="150"
y="312.36218" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="336.85547"
y="326.83582"
id="text3175"><tspan
sodipodi:role="line"
id="tspan3177"
x="336.85547"
y="326.83582">Menus &amp; Toolbars</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="562.50488"
y="362.36218"
id="text3179"><tspan
sodipodi:role="line"
id="tspan3181"
x="562.50488"
y="362.36218">Workflow</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="165.0498"
y="362.36218"
id="text3187"><tspan
sodipodi:role="line"
id="tspan3189"
x="165.0498"
y="362.36218">Navigator</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="380.26953"
y="442.36218"
id="text3191"><tspan
sodipodi:role="line"
id="tspan3193"
x="380.26953"
y="442.36218">Plots</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="303.29297"
y="602.36218"
id="text3195"><tspan
sodipodi:role="line"
id="tspan3197"
x="303.29297"
y="602.36218">Log, Selections &amp; Extensions</tspan></text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 7.0 KiB

68
fluents Executable file
View File

@ -0,0 +1,68 @@
#!/usr/bin/python2.4
from getopt import getopt
import sys
from system import fluents, project, workflow
import workflows
PROGRAM_NAME = 'fluents'
VERSION = '0.1.0'
parameters = {'workflow': workflow.EmptyWorkflow}
def show_help():
print 'fluent %s' % VERSION
print 'This software is released under the GNU General Public Licence'
print
print 'Usage: fluent [options]'
print
print 'Description:'
print ' Fluent is a lightweight data analysis application for bilinear models.'
print
print 'Options:'
print ' -h --help Show this help text'
print ' -l --list-workflows Lists available workflows'
print ' -w --workflow=<wf> Generates a new project based on workflow wf.'
print
def list_workflows():
print 'fluent %s' % VERSION
print
print 'Workflows:'
wfs = workflow.workflow_list()
for wf in wfs:
print ' %s (%s)' % (wf.ident, wf.name)
print
def parse_options():
short_opts = 'hlw:'
long_opts = ['help', 'list-workflows', 'workflow=']
options, params = getopt(sys.argv[1:], short_opts, long_opts)
for opt, val in options:
if opt in ['-h', '--help']:
show_help()
sys.exit(0)
elif opt in ['-l', '--list-workflows']:
list_workflows()
sys.exit(0)
elif opt in ['-w', '--workflow']:
wfs = workflow.workflow_list()
for wf in wfs:
if wf.ident == val:
parameters['workflow'] = wf
parameters['workflow']
if __name__ == '__main__':
parse_options()
import gtk
import gnome
gnome.program_init(PROGRAM_NAME, VERSION)
app = fluents.FluentApp(parameters['workflow'])
app.set_project(project.Project())
app.show()
gtk.main()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 621 B

After

Width:  |  Height:  |  Size: 666 B

View File

@ -11,16 +11,35 @@
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16px"
height="16px"
id="svg8468"
id="svg1617"
sodipodi:version="0.32"
inkscape:version="0.43"
sodipodi:docbase="/home/flatberg/laydi/icons"
sodipodi:docbase="/home/flatberg/fluent/icons"
sodipodi:docname="category_dataset.svg"
inkscape:export-filename="/home/flatberg/laydi/icons/category_dataset.png"
inkscape:export-filename="/home/flatberg/fluent/icons/dataset.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs8470">
id="defs1619">
<linearGradient
id="linearGradient9542">
<stop
style="stop-color:#978e8e;stop-opacity:1;"
offset="0"
id="stop9544" />
<stop
id="stop13091"
offset="0.2857143"
style="stop-color:#837d9e;stop-opacity:0.49803922;" />
<stop
style="stop-color:#b075a6;stop-opacity:0.24705882;"
offset="1"
id="stop13093" />
<stop
style="stop-color:#6f6daf;stop-opacity:0;"
offset="1"
id="stop9546" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient8653">
@ -34,52 +53,40 @@
id="stop8657" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient8653"
id="linearGradient1362"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.048746,-7.497414e-10,1.276627e-10,0.992725,0.504498,4.555838)"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076" />
<linearGradient
id="linearGradient9542">
id="linearGradient2500">
<stop
style="stop-color:#a0a0a0;stop-opacity:0.85123968;"
style="stop-color:#a8a8a8;stop-opacity:1;"
offset="0"
id="stop9544" />
id="stop2502" />
<stop
id="stop7591"
offset="0.14835165"
style="stop-color:#918e9f;stop-opacity:0.6745098;" />
id="stop3387"
offset="0.75510204"
style="stop-color:#e5e5e5;stop-opacity:0.96907216;" />
<stop
id="stop13091"
offset="0.2857143"
style="stop-color:#837d9e;stop-opacity:0.49803922;" />
<stop
style="stop-color:#7975a6;stop-opacity:0.24705882;"
offset="0.56043959"
id="stop13093" />
<stop
id="stop7593"
style="stop-color:#ebebeb;stop-opacity:0;"
offset="1"
style="stop-color:#7471aa;stop-opacity:0.12156863;" />
<stop
style="stop-color:#6f6daf;stop-opacity:0;"
offset="1"
id="stop9546" />
id="stop2504" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9542"
id="linearGradient1360"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.048746,-7.497414e-10,1.276627e-10,0.992725,0.504498,4.555838)"
xlink:href="#linearGradient8653"
id="linearGradient8659"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076" />
y2="3.2324076"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.786559,-6.091642e-10,9.574695e-11,0.806589,-3.626117,6.632697)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9542"
id="linearGradient9548"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.786559,-6.091642e-10,9.574695e-11,0.806589,-3.626117,6.632697)" />
</defs>
<sodipodi:namedview
id="base"
@ -90,17 +97,17 @@
inkscape:pageshadow="2"
inkscape:zoom="22.197802"
inkscape:cx="8"
inkscape:cy="7.1848042"
inkscape:cy="8"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="749"
inkscape:window-height="540"
inkscape:window-x="0"
inkscape:window-y="0" />
inkscape:window-x="136"
inkscape:window-y="107" />
<metadata
id="metadata8473">
id="metadata1622">
<rdf:RDF>
<cc:Work
rdf:about="">
@ -115,90 +122,105 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<rect
style="opacity:1;fill:#878e8e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect9550"
width="0.82326102"
height="14.495289"
x="-16.045271"
y="1.0721804"
transform="matrix(-3.116999e-4,-1,1,-1.970668e-4,0,0)" />
<rect
style="opacity:0.95890407;fill:url(#linearGradient1360);fill-opacity:1;stroke:url(#linearGradient1362);stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:1;fill:url(#linearGradient9548);fill-opacity:1;stroke:url(#linearGradient8659);stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect1625"
width="15.193709"
height="15.375698"
x="-15.219335"
y="0.076888956"
transform="matrix(-1.479312e-3,-0.999999,0.999999,-1.658227e-3,0,0)" />
width="11.395269"
height="12.492741"
x="-15.41898"
y="2.9935551"
transform="matrix(-1.602589e-3,-0.999999,0.999999,-1.530673e-3,0,0)" />
<rect
style="opacity:1;fill:#878e8e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect3393"
width="0.62086815"
height="15.000007"
x="15.456053"
y="1" />
width="0.50445545"
height="11.522277"
x="15.495544"
y="4.4777226" />
<rect
style="opacity:1;fill:#fa96c7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect9550"
width="0.59595656"
height="11.990877"
x="-16.000607"
y="3.4989688"
transform="matrix(-3.561914e-4,-1,1,-1.724514e-4,0,0)" />
<rect
style="fill:#e7577b;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;opacity:0.49746193"
id="rect11308"
width="3.692307"
height="4.0000019"
x="1.307693"
y="1.333333" />
width="3"
height="3"
x="4"
y="5" />
<rect
style="fill:#e68ab8;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#e7577b;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect12183"
width="3.692307"
height="4.0000019"
x="1.307693"
y="6.0000024" />
width="3"
height="3"
x="4"
y="8.5" />
<rect
style="fill:#cc7aa3;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#e7577b;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect12185"
width="3.692307"
height="4.0000019"
x="1.307693"
y="10.666672" />
width="3"
height="3"
x="4"
y="12" />
<rect
style="opacity:1;fill:#fa96d5;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.49746195;fill:#d9728e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13079"
width="3.692307"
height="4.0000019"
x="5.8669081"
y="1.333333" />
width="3"
height="3"
x="7.5945544"
y="5" />
<rect
style="fill:#e68ac4;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#d9728e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13081"
width="3.692307"
height="4.0000019"
x="5.8669081"
y="6.0000024" />
width="3"
height="3"
x="7.5945544"
y="8.5" />
<rect
style="fill:#cc7aae;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#d9728e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13083"
width="3.692307"
height="4.0000019"
x="5.8669081"
y="10.666674" />
width="3"
height="3"
x="7.5945544"
y="12.000001" />
<rect
style="opacity:1;fill:#fa96e1;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.49746195;fill:#f4909c;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13085"
width="3.692307"
height="4.0000019"
x="10.617668"
y="1.3333318" />
width="3"
height="3"
x="11.564356"
y="4.999999" />
<rect
style="fill:#e68acf;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#f4909c;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13087"
width="3.692307"
height="4.0000019"
x="10.617668"
y="6.0000014" />
width="3"
height="3"
x="11.564356"
y="8.499999" />
<rect
style="fill:#cc7ab8;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#f4909c;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13089"
width="3.692307"
height="4.0000019"
x="10.617668"
y="10.666672" />
width="3"
height="3"
x="11.564356"
y="12" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13095"
width="1"
height="1.9999686"
x="-10.45223"
y="0.99966687"
transform="matrix(-3.540536e-5,-1,0.999998,-1.734922e-3,0,0)" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13097"
width="1"
height="16"
x="0"
y="0" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 B

After

Width:  |  Height:  |  Size: 671 B

View File

@ -14,35 +14,24 @@
id="svg1617"
sodipodi:version="0.32"
inkscape:version="0.43"
sodipodi:docbase="/home/flatberg/laydi/icons"
sodipodi:docname="dataset.svg"
inkscape:export-filename="/home/flatberg/laydi/icons/dataset.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
sodipodi:docbase="/home/flatberg/fluent/icons"
sodipodi:docname="dataset.svg">
<defs
id="defs1619">
<linearGradient
id="linearGradient9542">
<stop
style="stop-color:#a0a0a0;stop-opacity:0.85123968;"
style="stop-color:#978e8e;stop-opacity:1;"
offset="0"
id="stop9544" />
<stop
id="stop7591"
offset="0.14835165"
style="stop-color:#918e9f;stop-opacity:0.6745098;" />
<stop
id="stop13091"
offset="0.2857143"
style="stop-color:#837d9e;stop-opacity:0.49803922;" />
<stop
style="stop-color:#7975a6;stop-opacity:0.24705882;"
offset="0.56043959"
id="stop13093" />
<stop
id="stop7593"
offset="1"
style="stop-color:#7471aa;stop-opacity:0.12156863;" />
id="stop13093" />
<stop
style="stop-color:#6f6daf;stop-opacity:0;"
offset="1"
@ -63,17 +52,13 @@
<linearGradient
id="linearGradient2500">
<stop
style="stop-color:#cacaca;stop-opacity:1;"
style="stop-color:#a8a8a8;stop-opacity:1;"
offset="0"
id="stop2502" />
<stop
id="stop3387"
offset="0.75510204"
style="stop-color:#e5e5e5;stop-opacity:0.96907216;" />
<stop
style="stop-color:#e8e8e8;stop-opacity:0.48627451;"
offset="0.75510204"
id="stop7589" />
<stop
style="stop-color:#ebebeb;stop-opacity:0;"
offset="1"
@ -81,24 +66,24 @@
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9542"
id="linearGradient1360"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.048746,-7.497408e-10,1.276627e-10,0.992725,0.504626,4.478908)"
xlink:href="#linearGradient8653"
id="linearGradient8659"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076" />
y2="3.2324076"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.786559,-6.091642e-10,9.574695e-11,0.806589,-3.626117,6.632697)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient8653"
id="linearGradient1362"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.048746,-7.497408e-10,1.276627e-10,0.992725,0.504626,4.478908)"
xlink:href="#linearGradient9542"
id="linearGradient9548"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076" />
y2="3.2324076"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.786559,-6.091642e-10,9.574695e-11,0.806589,-3.626117,6.632697)" />
</defs>
<sodipodi:namedview
id="base"
@ -116,8 +101,8 @@
inkscape:document-units="px"
inkscape:window-width="749"
inkscape:window-height="540"
inkscape:window-x="236"
inkscape:window-y="35" />
inkscape:window-x="136"
inkscape:window-y="107" />
<metadata
id="metadata1622">
<rdf:RDF>
@ -134,90 +119,105 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<rect
style="opacity:1;fill:#878e8e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect9550"
width="0.8232609"
height="14.495289"
x="-16.045254"
y="0.99525535"
transform="matrix(-3.116999e-4,-1,1,-1.970668e-4,0,0)" />
<rect
style="fill:url(#linearGradient1360);fill-opacity:1.0;stroke:url(#linearGradient1362);stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;opacity:0.95890411"
style="opacity:1;fill:url(#linearGradient9548);fill-opacity:1;stroke:url(#linearGradient8659);stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect1625"
width="15.193706"
height="15.375687"
x="-15.219205"
y="-3.7501515e-05"
transform="matrix(-1.479312e-3,-0.999999,0.999999,-1.658229e-3,0,0)" />
width="11.395269"
height="12.492741"
x="-15.41898"
y="2.9935551"
transform="matrix(-1.602589e-3,-0.999999,0.999999,-1.530673e-3,0,0)" />
<rect
style="opacity:1;fill:#878e8e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect3393"
width="0.62086815"
height="15.000007"
x="15.379128"
y="1" />
width="0.50445545"
height="11.522277"
x="15.495544"
y="4.4777226" />
<rect
style="opacity:1;fill:#96c8fa;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect9550"
width="0.59595656"
height="11.990877"
x="-16.000607"
y="3.4989688"
transform="matrix(-3.561914e-4,-1,1,-1.724514e-4,0,0)" />
<rect
style="fill:#5797e7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;opacity:0.49746193"
id="rect11308"
width="3.692307"
height="4.0000019"
x="1.230768"
y="1.333333" />
width="3"
height="3"
x="4"
y="5" />
<rect
style="fill:#8ab8e6;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#5797e7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect12183"
width="3.692307"
height="4.0000019"
x="1.230768"
y="6.0000019" />
width="3"
height="3"
x="4"
y="8.5" />
<rect
style="fill:#7ba4cc;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#5797e7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect12185"
width="3.692307"
height="4.0000019"
x="1.230768"
y="10.666671" />
width="3"
height="3"
x="4"
y="12" />
<rect
style="opacity:1;fill:#96d5fa;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.49746195;fill:#57ade7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13079"
width="3.692307"
height="4.0000019"
x="5.7899828"
y="1.333333" />
width="3"
height="3"
x="7.5945544"
y="5" />
<rect
style="fill:#8ac4e6;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#57ade7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13081"
width="3.692307"
height="4.0000019"
x="5.7899828"
y="6.0000019" />
width="3"
height="3"
x="7.5945544"
y="8.5" />
<rect
style="fill:#7baecc;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#57ade7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13083"
width="3.692307"
height="4.0000019"
x="5.7899828"
y="10.666673" />
width="3"
height="3"
x="7.5945544"
y="12.000001" />
<rect
style="opacity:1;fill:#96e1fa;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.49746195;fill:#57c2e7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13085"
width="3.692307"
height="4.0000019"
x="10.540743"
y="1.3333317" />
width="3"
height="3"
x="11.564356"
y="4.999999" />
<rect
style="fill:#8acfe6;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#57c2e7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13087"
width="3.692307"
height="4.0000019"
x="10.540743"
y="6.000001" />
width="3"
height="3"
x="11.564356"
y="8.499999" />
<rect
style="fill:#7bb8cc;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="fill:#57c2e7;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13089"
width="3.692307"
height="4.0000019"
x="10.540743"
y="10.666671" />
width="3"
height="3"
x="11.564356"
y="12" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13095"
width="1"
height="1.9999686"
x="-10.45223"
y="0.99966687"
transform="matrix(-3.540536e-5,-1,0.999998,-1.734922e-3,0,0)" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13097"
width="1"
height="16"
x="0"
y="0" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 835 B

After

Width:  |  Height:  |  Size: 762 B

View File

@ -11,49 +11,61 @@
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16px"
height="16px"
id="svg8468"
id="svg1617"
sodipodi:version="0.32"
inkscape:version="0.43"
sodipodi:docbase="/home/flatberg/laydi/icons"
sodipodi:docbase="/home/flatberg/fluent/icons"
sodipodi:docname="graph_dataset.svg"
inkscape:export-filename="/home/flatberg/laydi/icons/graph_dataset.png"
inkscape:export-filename="/home/flatberg/fluent/icons/graph_dataset.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs8470">
id="defs1619">
<marker
inkscape:stockid="TriangleOutS"
inkscape:stockid="Dot_s"
orient="auto"
refY="0.0"
refX="0.0"
id="TriangleOutS"
id="Dot_s"
style="overflow:visible">
<path
id="path10489"
d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
transform="scale(0.2)" />
id="path23705"
d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;marker-end:none"
transform="scale(0.2) translate(7.125493, 1)" />
</marker>
<marker
inkscape:stockid="DistanceIn"
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="DistanceIn"
id="Arrow1Lstart"
style="overflow:visible">
<g
id="g10541"
transform="scale(0.6,0.6) translate(8,0)">
<path
id="path10543"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" />
<path
id="path10545"
d="M -14.759949,-7 L -14.759949,65"
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.2pt;marker-start:none" />
</g>
<path
id="path23776"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
transform="scale(0.8)" />
</marker>
<linearGradient
id="linearGradient9542">
<stop
style="stop-color:#978e8e;stop-opacity:1;"
offset="0"
id="stop9544" />
<stop
id="stop13091"
offset="0.2857143"
style="stop-color:#837d9e;stop-opacity:0.49803922;" />
<stop
style="stop-color:#b075a6;stop-opacity:0.24705882;"
offset="1"
id="stop13093" />
<stop
style="stop-color:#6f6daf;stop-opacity:0;"
offset="1"
id="stop9546" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient8653">
@ -67,52 +79,40 @@
id="stop8657" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient8653"
id="linearGradient1362"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.048746,-7.497414e-10,1.276627e-10,0.992725,0.504498,4.555838)"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076" />
<linearGradient
id="linearGradient9542">
id="linearGradient2500">
<stop
style="stop-color:#a0a0a0;stop-opacity:0.85123968;"
style="stop-color:#a8a8a8;stop-opacity:1;"
offset="0"
id="stop9544" />
id="stop2502" />
<stop
id="stop7591"
offset="0.14835165"
style="stop-color:#918e9f;stop-opacity:0.6745098;" />
id="stop3387"
offset="0.75510204"
style="stop-color:#e5e5e5;stop-opacity:0.96907216;" />
<stop
id="stop13091"
offset="0.2857143"
style="stop-color:#837d9e;stop-opacity:0.49803922;" />
<stop
style="stop-color:#7975a6;stop-opacity:0.24705882;"
offset="0.56043959"
id="stop13093" />
<stop
id="stop7593"
style="stop-color:#ebebeb;stop-opacity:0;"
offset="1"
style="stop-color:#7471aa;stop-opacity:0.12156863;" />
<stop
style="stop-color:#6f6daf;stop-opacity:0;"
offset="1"
id="stop9546" />
id="stop2504" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9542"
id="linearGradient1360"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.048746,-7.497414e-10,1.276627e-10,0.992725,0.504498,4.555838)"
xlink:href="#linearGradient8653"
id="linearGradient8659"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076" />
y2="3.2324076"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.786559,-6.091644e-10,9.574701e-11,0.806589,-3.750022,6.643764)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9542"
id="linearGradient9548"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.786559,-6.091644e-10,9.574701e-11,0.806589,-3.750022,6.643764)" />
</defs>
<sodipodi:namedview
id="base"
@ -121,19 +121,19 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="31.392433"
inkscape:cx="8"
inkscape:cy="8.3153731"
inkscape:zoom="44.395604"
inkscape:cx="7.3431998"
inkscape:cy="7.7311881"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="992"
inkscape:window-height="672"
inkscape:window-width="1280"
inkscape:window-height="955"
inkscape:window-x="0"
inkscape:window-y="0" />
<metadata
id="metadata8473">
id="metadata1622">
<rdf:RDF>
<cc:Work
rdf:about="">
@ -148,112 +148,127 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<rect
style="opacity:1;fill:#878e8e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect9550"
width="0.82326102"
height="14.495289"
x="-16.045271"
y="1.0721804"
transform="matrix(-3.116999e-4,-1,1,-1.970668e-4,0,0)" />
<rect
style="opacity:0.95890407;fill:url(#linearGradient1360);fill-opacity:1;stroke:url(#linearGradient1362);stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:1;fill:url(#linearGradient9548);fill-opacity:1;stroke:url(#linearGradient8659);stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect1625"
width="15.193709"
height="15.375698"
x="-15.219335"
y="0.076888956"
transform="matrix(-1.479312e-3,-0.999999,0.999999,-1.658227e-3,0,0)" />
width="11.395275"
height="12.492744"
x="-15.542892"
y="3.0046201"
transform="matrix(-1.602589e-3,-0.999999,0.999999,-1.530673e-3,0,0)" />
<rect
style="opacity:1;fill:#878e8e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect3393"
width="0.62086815"
height="15.000007"
x="15.456053"
y="1" />
width="0.50445545"
height="11.522277"
x="15.495544"
y="4.4777226" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect9550"
width="0.59595656"
height="11.990877"
x="-16.000607"
y="3.4989688"
transform="matrix(-3.561914e-4,-1,1,-1.724514e-4,0,0)" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13095"
width="1"
height="1.9999686"
x="-10.45223"
y="0.99966687"
transform="matrix(-3.540536e-5,-1,0.999998,-1.734922e-3,0,0)" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13097"
width="1"
height="16"
x="0"
y="0" />
<path
sodipodi:type="arc"
style="opacity:1;fill:#fce100;fill-opacity:1;stroke:#000000;stroke-width:0.11344237;stroke-linecap:square;stroke-linejoin:round;marker-start:none;stroke-miterlimit:0.60000002;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.89847711;fill:#eb9213;fill-opacity:1;stroke:#000000;stroke-width:0.11331103;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path17466"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1676788,5.8311826"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1507906,5.6771397"
sodipodi:start="0"
sodipodi:end="6.2052379"
transform="matrix(1.253157,0,0,1.113406,-3.467103,-3.568938)"
sodipodi:open="true" />
sodipodi:end="6.1067046"
sodipodi:open="true"
transform="matrix(0.936447,0,0,0.831711,0.751641,1.359412)" />
<path
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.26768968;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 4.2658336,3.1945274 C 6.8661552,3.3651026 6.8661552,3.3651026 6.8661552,3.3651026"
sodipodi:type="arc"
style="opacity:1;fill:#eb9213;fill-opacity:1;stroke:#000000;stroke-width:0.11331103;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;stroke-linecap:round;marker-start:none"
id="path18341"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1507906,5.6771397"
sodipodi:start="0"
sodipodi:end="6.1067046"
sodipodi:open="true"
transform="matrix(0.936447,0,0,0.831711,5.220453,1.73664)" />
<path
sodipodi:type="arc"
style="opacity:0.89847711;fill:#eb9213;fill-opacity:1;stroke:#000000;stroke-width:0.11331103;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path18343"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1507906,5.6771397"
sodipodi:start="0"
sodipodi:end="6.1067046"
sodipodi:open="true"
transform="matrix(0.936447,0,0,0.831711,1.369384,5.359412)" />
<path
sodipodi:type="arc"
style="opacity:0.89847711;fill:#eb9213;fill-opacity:1;stroke:#000000;stroke-width:0.11331103;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path18345"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1507906,5.6771397"
sodipodi:start="0"
sodipodi:end="6.1067046"
sodipodi:open="true"
transform="matrix(0.936447,0,0,0.831711,8.751641,8.73664)" />
<path
sodipodi:type="arc"
style="opacity:0.89847711;fill:#eb9213;fill-opacity:1;stroke:#000000;stroke-width:0.11331103;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path18347"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1507906,5.6771397"
sodipodi:start="0"
sodipodi:end="6.1067046"
sodipodi:open="true"
transform="matrix(0.936447,0,0,0.831711,5.751641,5.73664)" />
<path
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 6.5302362,6.411702 C 8.4733797,6.5391212 8.4733797,6.5391212 8.4733797,6.5391212"
id="path19226" />
<path
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.26768968;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 5.0544557,8.6955802 C 7.6547772,8.8661552 7.6547772,8.8661552 7.6547772,8.8661552"
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 7.1195502,10.520973 C 9.0626937,10.648392 9.0626937,10.648392 9.0626937,10.648392"
id="path20976" />
<path
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.22983284;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 10.454515,10.171792 C 12.073852,11.750404 12.073852,11.750404 12.073852,11.750404"
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.17171589;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 11.154855,11.623699 C 12.364938,12.802918 12.364938,12.802918 12.364938,12.802918"
id="path20978" />
<path
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.21246541;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 8.7957709,5.2752684 C 8.9799765,7.2018145 8.9799765,7.2018145 8.9799765,7.2018145"
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.15874009;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 9.9153246,7.9660097 C 10.052976,9.4051342 10.052976,9.4051342 10.052976,9.4051342"
id="path20980" />
<path
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.21246541;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 2.7355425,4.8083416 C 3.0326879,6.7207162 3.0326879,6.7207162 3.0326879,6.7207162"
style="opacity:1;color:#000000;fill:#3a383b;fill-opacity:0.82485878;fill-rule:evenodd;stroke:#000000;stroke-width:0.15874009;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 5.3866948,7.6172167 C 5.6087428,9.0457551 5.6087428,9.0457551 5.6087428,9.0457551"
id="path20982" />
<path
sodipodi:type="arc"
style="opacity:1;fill:#fce100;fill-opacity:1;stroke:#000000;stroke-width:0.11344237;stroke-linecap:round;stroke-linejoin:round;marker-start:none;stroke-miterlimit:0.60000002;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path11491"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1712767,5.9108317"
sodipodi:start="0"
sodipodi:end="6.2558287"
transform="matrix(1.253157,0,0,1.113406,2.563866,-3.062839)"
sodipodi:open="true" />
<path
sodipodi:type="arc"
style="opacity:1;fill:#fce100;fill-opacity:1;stroke:#000000;stroke-width:0.11344237;stroke-linecap:square;stroke-linejoin:round;marker-start:none;stroke-miterlimit:0.60000002;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path11493"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1687496,5.8483902"
sodipodi:start="0"
sodipodi:end="6.2161801"
sodipodi:open="true"
transform="matrix(1.253157,0,0,1.113406,-2.616827,1.847557)" />
<path
sodipodi:type="arc"
style="opacity:1;fill:#fce100;fill-opacity:1;stroke:#000000;stroke-width:0.11344237;stroke-linecap:square;stroke-linejoin:round;marker-start:none;stroke-miterlimit:0.60000002;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path11495"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1677975,5.8329691"
sodipodi:start="0"
sodipodi:end="6.2063743"
sodipodi:open="true"
transform="matrix(1.253157,0,0,1.113406,3.14951,2.388151)" />
<path
sodipodi:type="arc"
style="opacity:1;fill:#fce100;fill-opacity:1;stroke:#000000;stroke-width:0.11344237;stroke-linecap:square;stroke-linejoin:round;marker-start:none;stroke-miterlimit:0.60000002;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path11497"
sodipodi:cx="4.8202972"
sodipodi:cy="5.9539604"
sodipodi:rx="1.3514851"
sodipodi:ry="1.5767326"
d="M 6.1717824,5.9539604 A 1.3514851,1.5767326 0 1 1 6.1678722,5.8341073"
sodipodi:start="0"
sodipodi:end="6.2070983"
sodipodi:open="true"
transform="matrix(1.253157,0,0,1.113406,7.198788,6.458182)" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 959 B

View File

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="48px"
height="48px"
id="svg1337"
sodipodi:version="0.32"
inkscape:version="0.43"
sodipodi:docbase="/home/flatberg/laydi/icons"
sodipodi:docname="lasso.svg"
inkscape:export-filename="/home/flatberg/laydi/icons/lasso.png"
inkscape:export-xdpi="37.5"
inkscape:export-ydpi="37.5">
<defs
id="defs1339" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7"
inkscape:cx="24"
inkscape:cy="24"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="749"
inkscape:window-height="540"
inkscape:window-x="0"
inkscape:window-y="155" />
<metadata
id="metadata1342">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:4,4;stroke-dashoffset:8.39999991;stroke-opacity:1"
d="M 21.5,5.5 C 15.071429,6.5 10.5,10.5 10.5,10.5 C 10.5,10.5 10.642857,9.2142857 7.6428571,15.214286 C 4.6428571,21.214286 16.071429,20.214285 17.214286,26.785714 C 18.357143,33.357143 25.5,40.5 30.5,40.5 C 35.5,40.5 38.5,35.5 38.5,32.5 C 38.5,29.5 38.5,29.5 38.5,29.5 C 38.5,29.5 31.850409,25.775944 34.642857,21.071429 C 37.808688,15.737865 37.5,5.7857143 21.5,5.5 z "
id="path2402"
sodipodi:nodetypes="ccsssscsc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 727 B

View File

@ -11,16 +11,13 @@
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16px"
height="16px"
id="svg8468"
id="svg1617"
sodipodi:version="0.32"
inkscape:version="0.43"
sodipodi:docbase="/home/flatberg/laydi/icons"
sodipodi:docname="line_plot.svg"
inkscape:export-filename="/home/flatberg/laydi/icons/line_plot.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
sodipodi:docbase="/home/flatberg/fluent/icons"
sodipodi:docname="line_plot.svg">
<defs
id="defs8470">
id="defs1619">
<marker
inkscape:stockid="SquareS"
orient="auto"
@ -35,42 +32,41 @@
transform="scale(0.2)" />
</marker>
<marker
inkscape:stockid="TriangleOutS"
inkscape:stockid="Arrow1Send"
orient="auto"
refY="0.0"
refX="0.0"
id="TriangleOutS"
style="overflow:visible">
id="Arrow1Send"
style="overflow:visible;">
<path
id="path10489"
d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
transform="scale(0.2)" />
</marker>
<marker
inkscape:stockid="DistanceIn"
orient="auto"
refY="0.0"
refX="0.0"
id="DistanceIn"
style="overflow:visible">
<g
id="g10541"
transform="scale(0.6,0.6) translate(8,0)">
<path
id="path10543"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" />
<path
id="path10545"
d="M -14.759949,-7 L -14.759949,65"
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.2pt;marker-start:none" />
</g>
id="path3456"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
transform="scale(0.2) rotate(180)" />
</marker>
<linearGradient
id="linearGradient9542">
<stop
style="stop-color:#1d8b3d;stop-opacity:1;"
offset="0"
id="stop9544" />
<stop
id="stop13091"
offset="0.2857143"
style="stop-color:#837d9e;stop-opacity:0.49803922;" />
<stop
style="stop-color:#7975a6;stop-opacity:0.24705882;"
offset="1"
id="stop13093" />
<stop
style="stop-color:#6f6daf;stop-opacity:0;"
offset="1"
id="stop9546" />
</linearGradient>
<linearGradient
id="linearGradient8653">
<stop
style="stop-color:#3def19;stop-opacity:0.97540987;"
style="stop-color:#23fd00;stop-opacity:1;"
offset="0"
id="stop8655" />
<stop
@ -79,52 +75,40 @@
id="stop8657" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient8653"
id="linearGradient1362"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.048746,-7.497417e-10,1.276627e-10,0.992725,0.504627,4.478913)"
x1="-13.565333"
y1="3.2233276"
x2="0.73984236"
y2="3.2456837" />
<linearGradient
id="linearGradient9542">
id="linearGradient2500">
<stop
style="stop-color:#13e414;stop-opacity:0.92622954;"
style="stop-color:#a8a8a8;stop-opacity:1;"
offset="0"
id="stop9544" />
id="stop2502" />
<stop
id="stop7591"
offset="0.14835165"
style="stop-color:#918e9f;stop-opacity:0.6745098;" />
id="stop3387"
offset="0.75510204"
style="stop-color:#e5e5e5;stop-opacity:0.96907216;" />
<stop
id="stop13091"
offset="0.2857143"
style="stop-color:#837d9e;stop-opacity:0.49803922;" />
<stop
style="stop-color:#7975a6;stop-opacity:0.24705882;"
offset="0.56043959"
id="stop13093" />
<stop
id="stop7593"
style="stop-color:#ebebeb;stop-opacity:0;"
offset="1"
style="stop-color:#7471aa;stop-opacity:0.12156863;" />
<stop
style="stop-color:#6f6daf;stop-opacity:0;"
offset="1"
id="stop9546" />
id="stop2504" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient8653"
id="linearGradient1360"
id="linearGradient8659"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.048746,-7.497417e-10,1.276627e-10,0.992725,0.504627,4.478913)"
x1="-13.565333"
y1="3.2233276"
x2="0.73984236"
y2="3.2456837" />
gradientTransform="matrix(0.786559,-6.091642e-10,9.574695e-11,0.806589,-3.626117,6.632697)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient8653"
id="linearGradient9548"
x1="-14.992936"
y1="3.2324076"
x2="-0.50547981"
y2="3.2324076"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.786559,-6.091642e-10,9.574695e-11,0.806589,-3.626117,6.632697)" />
</defs>
<sodipodi:namedview
id="base"
@ -133,19 +117,19 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="31.392433"
inkscape:cx="8"
inkscape:cy="8.1498335"
inkscape:zoom="22.197802"
inkscape:cx="8.4320071"
inkscape:cy="4.4085456"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="1024"
inkscape:window-height="699"
inkscape:window-x="0"
inkscape:window-y="0" />
inkscape:window-width="914"
inkscape:window-height="712"
inkscape:window-x="237"
inkscape:window-y="43" />
<metadata
id="metadata8473">
id="metadata1622">
<rdf:RDF>
<cc:Work
rdf:about="">
@ -160,42 +144,57 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<rect
style="opacity:1;fill:#878e8e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect9550"
width="0.82326102"
height="14.495289"
x="-16.045271"
y="1.0721804"
transform="matrix(-3.116999e-4,-1,1,-1.970668e-4,0,0)" />
<rect
style="opacity:0.95890407;fill:url(#linearGradient1360);fill-opacity:1.0;stroke:url(#linearGradient1362);stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:1;fill:url(#linearGradient9548);fill-opacity:1.0;stroke:url(#linearGradient8659);stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect1625"
width="15.193711"
height="15.375704"
x="-15.219207"
y="-3.7717124e-05"
transform="matrix(-1.479312e-3,-0.999999,0.999999,-1.658226e-3,0,0)" />
width="11.395269"
height="12.492741"
x="-15.41898"
y="2.9935551"
transform="matrix(-1.602589e-3,-0.999999,0.999999,-1.530673e-3,0,0)" />
<rect
style="opacity:1;fill:#878e8e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect3393"
width="0.62086815"
height="15.000007"
x="15.456053"
y="1" />
width="0.50445545"
height="11.522277"
x="15.495544"
y="4.4777226" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect9550"
width="0.59595656"
height="11.990877"
x="-16.000607"
y="3.4989688"
transform="matrix(-3.561914e-4,-1,1,-1.724514e-4,0,0)" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13095"
width="1"
height="1.9999686"
x="-10.45223"
y="0.99966687"
transform="matrix(-3.540536e-5,-1,0.999998,-1.734922e-3,0,0)" />
<rect
style="opacity:0.86243388;fill:#929797;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect13097"
width="1"
height="16"
x="0"
y="0" />
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:0.33539712;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:url(#SquareS);marker-mid:url(#SquareS);marker-end:url(#SquareS);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 1.6021029,2.0851203 C 1.6021029,13.166175 1.5938478,13.166175 1.5938478,13.166175 L 1.5938478,13.166175"
style="opacity:1;color:#000000;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:0.30343372;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:url(#SquareS);marker-mid:url(#SquareS);marker-end:url(#SquareS);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 3.8080234,4.8809418 C 3.8080234,14.496824 3.8002372,14.496824 3.8002372,14.496824 L 3.8002372,14.496824"
id="path2423" />
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:0.39048415;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:url(#SquareS);marker-mid:url(#SquareS);marker-end:url(#SquareS);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 13.834879,7.5459964 C 1.5976484,7.5140078 1.5977289,7.5038756 1.5977289,7.5038756 L 1.5977289,7.5038756"
style="opacity:1;color:#000000;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:0.35327095;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:url(#SquareS);marker-mid:url(#SquareS);marker-end:url(#SquareS);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 15.345903,9.6197631 C 3.8038219,9.5920041 3.8038979,9.5832116 3.8038979,9.5832116 L 3.8038979,9.5832116"
id="path3480" />
<path
style="opacity:1;color:#000000;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#fa0707;stroke-width:0.563;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 2.12371,8.7908287 C 2.12371,8.7908287 2.1247276,4.7218426 3.7295633,3.4907823 C 5.0096068,2.5088681 6.2408535,6.6691258 6.6808795,7.6233413 C 7.3634493,9.1035237 7.752097,11.550423 9.1023444,11.744491 C 10.594787,11.958997 11.174836,10.169755 11.557138,9.2061391 C 12.261733,7.4301658 12.889508,4.7161739 12.889508,4.7161739 C 12.889508,4.7161739 13.367136,3.0354678 13.128322,3.0030216"
style="opacity:1;color:#000000;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#c72124;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
d="M 4.3,10.7 C 4.3,10.7 4.3009598,7.1690281 5.8146309,6.1007426 C 7.0219601,5.2486603 8.1832644,8.8588352 8.5982942,9.6868812 C 9.2420898,10.971349 9.6086599,13.094711 10.882205,13.263119 C 12.289868,13.449262 12.836966,11.8966 13.197551,11.060396 C 13.862121,9.519248 14.454234,7.1641089 14.454234,7.1641089 C 14.454234,7.1641089 14.90473,5.7056312 14.679482,5.6774752"
id="path3482"
sodipodi:nodetypes="csssscs"
inkscape:export-filename="/home/flatberg/laydi/icons/line_plot.png"
inkscape:export-filename="/home/flatberg/fluent/icons/line_plot.png"
inkscape:export-xdpi="130.40465"
inkscape:export-ydpi="130.40465" />
</g>

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -1,176 +0,0 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"
[
<!ATTLIST svg
xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
]>
<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
<svg
width="128pt"
height="128pt"
id="svg1"
sodipodi:version="0.27"
sodipodi:docname="/mnt/windows/Themes/Work/Blue-Sphere/move.svg"
sodipodi:docbase="/mnt/windows/Themes/Work/Blue-Sphere/"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs
id="defs22">
<linearGradient
id="linearGradient168">
<stop
offset="0.000000"
style="stop-color:#cdffff;stop-opacity:1;"
id="stop169" />
<stop
offset="1.000000"
style="stop-color:#0c5d7d;stop-opacity:0.905882;"
id="stop170" />
</linearGradient>
<linearGradient
id="linearGradient90">
<stop
offset="0.000000"
style="stop-color:#cdffff;stop-opacity:1;"
id="stop91" />
<stop
offset="1.000000"
style="stop-color:#006b97;stop-opacity:0.905882;"
id="stop92" />
</linearGradient>
<linearGradient
id="linearGradient67">
<stop
offset="0.000000"
style="stop-color:#d7ffff;stop-opacity:0.898039;"
id="stop70" />
<stop
offset="1.000000"
style="stop-color:#2ea6b9;stop-opacity:0.952941;"
id="stop69" />
</linearGradient>
<linearGradient
id="linearGradient57">
<stop
offset="0.000000"
style="stop-color:#ffffff;stop-opacity:1;"
id="stop59" />
<stop
offset="1.000000"
style="stop-color:#797979;stop-opacity:1;"
id="stop58" />
</linearGradient>
<defs
id="defs4">
<radialGradient
id="1"
cx="869.603027"
cy="1973.579956"
r="2106.649902"
fx="869.603027"
fy="1973.579956"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient67" />
</defs>
<defs
id="defs11">
<linearGradient
id="2"
x1="255.848"
y1="119.147"
x2="375.686"
y2="34.1009"
gradientUnits="userSpaceOnUse">
<stop
offset="0"
style="stop-color:#ffffff"
id="stop13" />
<stop
offset="1"
style="stop-color:#000000"
id="stop14" />
</linearGradient>
</defs>
<defs
id="defs16">
<linearGradient
id="3"
x1="275.053009"
y1="109.384003"
x2="356.480988"
y2="30.864300"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient57" />
</defs>
<radialGradient
cx="3.03981e-14"
cy="1.05578e-10"
r="0.773346"
fx="3.03981e-14"
fy="1.05578e-10"
xlink:href="#linearGradient168"
id="radialGradient88"
gradientUnits="objectBoundingBox"
gradientTransform="matrix(0.945877,0,0,1.05722,0.264368,0.249996)"
spreadMethod="pad" />
<linearGradient
x1="2.69643"
y1="1.14655"
x2="3.85147"
y2="0.623116"
xlink:href="#linearGradient67"
id="linearGradient89"
gradientUnits="objectBoundingBox"
gradientTransform="translate(-2.65767,-0.201241)"
spreadMethod="pad" />
</defs>
<sodipodi:namedview
id="base">
<sodipodi:guide
orientation="horizontal"
position="114.876968"
id="sodipodi:guide589" />
<sodipodi:guide
orientation="vertical"
position="47.041008"
id="sodipodi:guide590" />
<sodipodi:guide
orientation="vertical"
position="83.381706"
id="sodipodi:guide655" />
<sodipodi:guide
orientation="horizontal"
position="76.921135"
id="sodipodi:guide1057" />
<sodipodi:guide
orientation="horizontal"
position="42.195583"
id="sodipodi:guide1058" />
</sodipodi:namedview>
<path
d="M 32.5 12 L 56.8988 34.5471 L 42.9771 34.8537 L 42.7252 61.5867 L 22.2748 61.5867 L 22.0229 34.8537 L 8.21868 35.1477 L 32.5 12 z "
transform="matrix(0.797584,0,0,1.24992,56.2305,-2.71824)"
style="stroke-width:3.72423;fill:#0c5d7d;stroke:#0c5d7d;stroke-opacity:0.99;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:0.992157;"
id="polygon3"
sodipodi:nodetypes="cccccccc" />
<path
d="M 32.5 12 L 56.8988 34.5471 L 42.9771 34.8537 L 42.0791 72.0798 L 21.6287 72.0798 L 22.0229 34.8537 L 8.21868 35.1477 L 32.5 12 z "
transform="matrix(9.95215e-19,0.781212,-1.22426,1.55963e-18,171.015,60.3555)"
style="stroke-width:3.72423;fill:#0c5d7d;stroke:#0c5d7d;stroke-opacity:0.99;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:0.992157;"
id="path651"
sodipodi:nodetypes="cccccccc" />
<path
d="M 32.5 12 L 56.8988 34.5471 L 42.9771 34.8537 L 42.7252 61.018 L 22.2748 61.018 L 22.0229 34.8537 L 8.21868 35.1477 L 32.5 12 z "
transform="matrix(-0.81341,2.07245e-18,-3.24781e-18,-1.27472,108.565,172.894)"
style="stroke-width:3.72423;fill:#0c5d7d;stroke:#0c5d7d;stroke-opacity:0.99;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:0.992157;"
id="path652"
sodipodi:nodetypes="cccccccc" />
<path
d="M 32.5 12 L 56.8988 34.5471 L 42.9771 34.8537 L 42.7252 69.8962 L 22.2748 69.8962 L 22.0229 34.8537 L 8.21868 35.1477 L 32.5 12 z "
transform="matrix(-3.07844e-18,-0.805497,1.26232,-4.82433e-18,-9.11143,111.473)"
style="stroke-width:3.72423;fill:#0c5d7d;stroke:#0c5d7d;stroke-opacity:0.99;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:0.992157;"
id="path653"
sodipodi:nodetypes="cccccccc" />
</svg>

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 780 B

View File

@ -1,346 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="744.09448819"
height="1052.3622047"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.43"
sodipodi:docbase="/home/einarr/src/laydi/icons"
sodipodi:docname="table_size.svg">
<defs
id="defs4">
<linearGradient
inkscape:collect="always"
id="linearGradient2192">
<stop
style="stop-color:#00d07c;stop-opacity:1;"
offset="0"
id="stop2194" />
<stop
style="stop-color:#00d07c;stop-opacity:0;"
offset="1"
id="stop2196" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient2182">
<stop
style="stop-color:#0000ff;stop-opacity:1;"
offset="0"
id="stop2184" />
<stop
style="stop-color:#0000ff;stop-opacity:0;"
offset="1"
id="stop2186" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2182"
id="linearGradient2188"
x1="425.21429"
y1="850.93365"
x2="425.21429"
y2="125.84373"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2198"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,155.2857)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2202"
gradientUnits="userSpaceOnUse"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404"
gradientTransform="translate(162.8571,155.2857)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2206"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(331.4286,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2221"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2223"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(162.8571,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2225"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(331.4286,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2235"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2237"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(162.8571,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2239"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(331.4286,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2247"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2249"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(162.8571,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2251"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(331.4286,155.2857)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2257"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(161.8571,160.5)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2260"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-1,160.5)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2275"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(161.8571,-4.7143)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2192"
id="linearGradient2278"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-1,-4.7143)"
x1="202.35713"
y1="426.64789"
x2="202.35713"
y2="223.78404" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="375"
inkscape:cy="520"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:window-width="823"
inkscape:window-height="583"
inkscape:window-x="91"
inkscape:window-y="59" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:url(#linearGradient2188);fill-opacity:1.0;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect1307"
width="517.14288"
height="517.14288"
x="125.71429"
y="235.21933"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:url(#linearGradient2260);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2190"
width="148.57143"
height="148.57143"
x="144.71428"
y="418.57648"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:url(#linearGradient2257);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2200"
width="148.57143"
height="148.57143"
x="307.57144"
y="418.57648"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:#f3f4f9;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2204"
width="148.57143"
height="148.57143"
x="476.14285"
y="418.57648"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:#f3f4f9;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2215"
width="148.57143"
height="148.57143"
x="144.71428"
y="583.79077"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:#f3f4f9;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2217"
width="148.57143"
height="148.57143"
x="307.57144"
y="583.79077"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:#f3f4f9;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2219"
width="148.57143"
height="148.57143"
x="476.14285"
y="583.79077"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:url(#linearGradient2278);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2229"
width="148.57143"
height="148.57143"
x="144.71428"
y="253.36218"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:url(#linearGradient2275);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2231"
width="148.57143"
height="148.57143"
x="307.57144"
y="253.36218"
inkscape:export-filename="/home/einarr/src/laydi/icons/rect2233.png"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
<rect
style="fill:#f3f4f9;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2233"
width="148.57143"
height="148.57143"
x="476.14285"
y="253.36218"
inkscape:export-xdpi="3.4739451"
inkscape:export-ydpi="3.4739451" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,3 +0,0 @@
import main

View File

@ -1,100 +0,0 @@
_dim_annotation_handlers = {}
def get_dim_annotations(dimname, annotation, ids):
"""Returns a list of annotations corresponding to the given ids in
dimension dimname"""
global _dim_annotation_handlers
if _dim_annotation_handlers.has_key(dimname):
return _dim_annotation_handlers[dimname].get_annotations(annotation, ids)
return None
def set_dim_handler(dimname, handler):
"""Set the handler for the given dimension."""
global _dim_annotation_handlers
_dim_annotation_handlers[dimname] = handler
def get_dim_handler(dimname):
"""Get the handler for the given dimension."""
global _dim_annotation_handlers
return _dim_annotation_handlers.get(dimname, None)
class AnnotationHandler:
def __init__(self):
pass
def get_annotations(self, annotationname, ids, default=None):
return None
def get_annotation_names(self):
return []
class DictAnnotationHandler(AnnotationHandler):
def __init__(self, d=None):
if d == None:
d = {}
self._dict = d
def get_annotations(self, annotationname, ids, default=None):
d = self._dict
retval = []
for id in ids:
if d[annotationname].has_key(id):
retval.append(d[annotationname][id])
else:
retval.append(default)
return retval
def add_annotations(self, annotationname, d):
self._dict[annotationname] = d
def get_annotation_names(self):
return self._dict.keys()
def read_annotations_file(filename):
"""Read annotations from file.
Reads annotations from a tab delimited file of the format::
dimname annotation_name1 annotation_name2 ...
id1 Foo 0.43
id2 Bar 0.59
"""
ann = DictAnnotationHandler()
dimname = None
annotation_dicts = []
annotation_names = []
fd = open(filename)
## Read the first line, which contains the dimension name and
## annotation names.
line = fd.readline()
values = [x.strip() for x in line.split('\t')]
dimname = values[0]
annotation_names = values[1:]
annotation_dicts = [{} for x in annotation_names]
## Read the lines containing the annotations. The first value on
## each line is an id along the dimension.
while line:
values = [x.strip() for x in line.split('\t')]
for i, x in enumerate(values[1:]):
annotation_dicts[i][values[0]] = x
line = fd.readline()
fd.close()
## Add everything to the annotation object and add the object to
## the specified dimension.
for i, a in enumerate(annotation_names):
ann.add_annotations(a, annotation_dicts[i])
_dim_annotation_handlers[dimname] = ann
return ann

File diff suppressed because it is too large Load Diff

View File

@ -1,862 +0,0 @@
from scipy import ndarray, atleast_2d, asarray, intersect1d, zeros
from scipy import empty, sparse, where
from scipy import sort as array_sort
from itertools import izip
import shelve
import copy
import re
class Universe(object):
def __init__(self, name):
self.name = name
self._ids = {}
def register(self, dim):
"""Increase reference count for identifiers in Dimension object dim"""
if dim.name != self.name:
return
for i in dim:
self._ids[i] = self._ids.get(i, 0) + 1
def unregister(self, dim):
"""Update reference count for identifiers in Dimension object dim
Update reference count for identifiers in Dimension object dim, and remove all
identifiers with a reference count of 0, as they do not (by definition) exist
any longer.
"""
if dim.name != self.name:
return
for i in dim:
refcount = self._ids[i]
if refcount == 1:
self._ids.pop(i)
else:
self._ids[i] -= 1
def __str__(self):
return "%s: %i elements, %i references" % (self.name, len(self._ids), sum(self._ids.values()))
def __contains__(self, element):
return self._ids.__contains__(element)
def __len__(self):
return len(self._ids)
def intersection(self, dim):
return set(self._ids).intersection(dim.idset)
class Dimension(object):
"""A Dimension represents the set of identifiers an object has along an axis.
"""
def __init__(self, name, ids=[]):
self.name = name
self.idset = set(ids)
self.idlist = list(ids)
def __getitem__(self, element):
return self.idlist[element]
def __getslice__(self, start, end):
return self.idlist[start:end]
def __contains__(self, element):
return self.idset.__contains__(element)
def __str__(self):
return "%s: %s" % (self.name, str(self.idlist))
def __len__(self):
return len(self.idlist)
def __iter__(self):
return iter(self.idlist)
def intersection(self, dim):
return self.idset.intersection(dim.idset)
class Dataset(object):
"""The Dataset base class.
A Dataset is an n-way array with defined string identifiers across
all dimensions.
example of use:
---
dim_name_rows = 'rows'
names_rows = ('row_a','row_b')
ids_1 = [dim_name_rows, names_rows]
dim_name_cols = 'cols'
names_cols = ('col_a','col_b','col_c','col_d')
ids_2 = [dim_name_cols, names_cols]
Array_X = rand(2,4)
data = Dataset(Array_X,(ids_1,ids_2),name="Testing")
dim_names = [dim for dim in data]
column_identifiers = [id for id in data['cols'].keys()]
column_index = [index for index in data['cols'].values()]
'cols' in data -> True
---
data = Dataset(rand(10,20)) (generates dims and ids (no links))
"""
def __init__(self, array, identifiers=None, name='Unnamed dataset'):
self._dims = [] #existing dimensions in this dataset
self._map = {} # internal mapping for dataset: identifier <--> index
self._name = name
self._identifiers = identifiers
if not isinstance(array, sparse.spmatrix):
array = atleast_2d(asarray(array))
# vector are column (array)
if array.shape[0] == 1:
array = array.T
self.shape = array.shape
if identifiers != None:
self._validate_identifiers(identifiers)
self._set_identifiers(identifiers, self._all_dims)
else:
self._identifiers = self._create_identifiers(self.shape, self._all_dims)
self._set_identifiers(self._identifiers, self._all_dims)
self._array = array
def __iter__(self):
"""Returns an iterator over dimensions of dataset."""
return self._dims.__iter__()
def __contains__(self,dim):
"""Returns True if dim is a dimension name in dataset."""
# return self._dims.__contains__(dim)
return self._map.__contains__(dim)
def __len__(self):
"""Returns the number of dimensions in the dataset"""
return len(self._map)
def __getitem__(self,dim):
"""Return the identifers along the dimension dim."""
return self._map[dim]
def _create_identifiers(self, shape, all_dims):
"""Creates dimension names and identifier names, and returns
identifiers."""
dim_names = ['rows','cols']
ids = []
for axis, n in enumerate(shape):
if axis < 2:
dim_suggestion = dim_names[axis]
else:
dim_suggestion = 'dim'
dim_suggestion = self._suggest_dim_name(dim_suggestion, all_dims)
identifier_creation = [str(axis) + "_" + i for i in map(str, range(n))]
ids.append((dim_suggestion, identifier_creation))
all_dims.add(dim_suggestion)
return ids
def _set_identifiers(self, identifiers, all_dims):
"""Creates internal mapping of identifiers structure."""
for dim, ids in identifiers:
pos_map = ReverseDict()
if dim not in self._dims:
self._dims.append(dim)
all_dims.add(dim)
else:
raise ValueError, "Dimension names must be unique whitin dataset"
for pos, id in enumerate(ids):
pos_map[id] = pos
self._map[dim] = pos_map
def _suggest_dim_name(self,dim_name,all_dims):
"""Suggests a unique name for dim and returns it"""
c = 0
new_name = dim_name
while new_name in all_dims:
new_name = dim_name + "_" + str(c)
c += 1
return new_name
def asarray(self):
"""Returns the numeric array (data) of dataset"""
if isinstance(self._array, sparse.spmatrix):
return self._array.toarray()
return self._array
def set_array(self, array):
"""Adds array as an ArrayType object.
A one-dim array is transformed to a two-dim array (row-vector)
"""
if not isinstance(array, type(self._array)):
raise ValueError("Input array of type: %s does not match existing array type: %s") %(type(array), type(self._array))
if self.shape != array.shape:
raise ValueError, "Input array must be of similar dimensions as dataset"
self._array = atleast_2d(asarray(array))
def get_name(self):
"""Returns dataset name"""
return self._name
def get_all_dims(self):
"""Returns all dimensions in project"""
return self._all_dims
def get_dim_name(self, axis=None):
"""Returns dim name for an axis, if no axis is provided it
returns a list of dims"""
if type(axis) == int:
return self._dims[axis]
else:
return [dim for dim in self._dims]
def common_dims(self, ds):
"""Returns a list of the common dimensions in the two datasets."""
dims = self.get_dim_name()
ds_dims = ds.get_dim_name()
return [d for d in dims if d in ds_dims]
def get_identifiers(self, dim, indices=None, sorted=False):
"""Returns identifiers along dim, sorted by position (index)
is optional.
You can optionally provide a list/ndarray of indices to get
only the identifiers of a given position.
Identifiers are the unique names (strings) for a variable in a
given dim. Index (Indices) are the Identifiers position in a
matrix in a given dim.
"""
if indices != None:
if len(indices) == 0:# if empty list or empty array
return []
if indices != None:
# be sure to match intersection
#indices = intersect1d(self.get_indices(dim),indices)
ids = [self._map[dim].reverse[i] for i in indices]
else:
if sorted == True:
ids = [self._map[dim].reverse[i] for i in array_sort(self._map[dim].values())]
else:
ids = self._map[dim].keys()
return ids
def get_indices(self, dim, idents=None):
"""Returns indices for identifiers along dimension.
You can optionally provide a list of identifiers to retrieve a
index subset.
Identifiers are the unique names (strings) for a variable in a
given dim. Index (Indices) are the Identifiers position in a
matrix in a given dim. If none of the input identifiers are
found an empty index is returned
"""
if not isinstance(idents, list) and not isinstance(idents, set):
raise ValueError("idents needs to be a list/set got: %s" %type(idents))
if idents == None:
index = array_sort(self._map[dim].values())
else:
index = [self._map[dim][key]
for key in idents if self._map[dim].has_key(key)]
return asarray(index)
def existing_identifiers(self, dim, idents):
"""Filters a list of identifiers to find those that are present in the
dataset.
The most common use of this function is to get a list of
identifiers who correspond one to one with the list of indices produced
when get_indices is given an identifier list. That is
ds.get_indices(dim, idents) and ds.exisiting_identifiers(dim, idents)
will have the same order.
@param dim: A dimension present in the dataset.
@param idents: A list of identifiers along the given dimension.
@return: A list of identifiers in the same order as idents, but
without elements not present in the dataset.
"""
if not isinstance(idents, list) and not isinstance(idents, set):
raise ValueError("idents needs to be a list/set got: %s" %type(idents))
return [key for key in idents if self._map[dim].has_key(key)]
def copy(self):
""" Returns deepcopy of dataset.
"""
return copy.deepcopy(self)
def subdata(self, dim, idents):
"""Returns a new dataset based on dimension and given identifiers.
"""
ds = self.copy()
indices = array_sort(ds.get_indices(dim, idents))
idents = ds.get_identifiers(dim, indices=indices)
if not idents:
raise ValueError("No of identifers from: \n%s \nfound in %s" %(str(idents), ds._name))
ax = [i for i, name in enumerate(ds._dims) if name == dim][0]
subarr = ds._array.take(indices, ax)
new_indices = range(len(idents))
ds._map[dim] = ReverseDict(zip(idents, new_indices))
ds.shape = tuple(len(ds._map[d]) for d in ds._dims)
ds.set_array(subarr)
return ds
def transpose(self):
"""Returns a copy of transpose of a dataset.
As for the moment: only support for 2D-arrays.
"""
assert(len(self.shape) == 2)
ds = self.copy()
ds._array = ds._array.T
ds._dims.reverse()
ds.shape = ds._array.shape
return ds
def _validate_identifiers(self, identifiers):
for dim_name, ids in identifiers:
if len(set(ids)) != len(ids):
raise ValueError("Identifiers not unique in : %s" %dim_name)
identifier_shape = [len(i[1]) for i in identifiers]
if len(identifier_shape) != len(self.shape):
raise ValueError("Identifier list length must equal array dims")
for ni, na in zip(identifier_shape, self.shape):
if ni != na:
raise ValueError, "Identifier-array mismatch: %s: (idents: %s, array: %s)" %(self._name, ni, na)
class CategoryDataset(Dataset):
"""The category dataset class.
A dataset for representing class information as binary
matrices (0/1-matrices).
There is support for using a less memory demanding, sparse format. The
prefered (default) format for a category dataset is the compressed sparse row
format (csr)
Always has linked dimension in first dim:
ex matrix:
. go_term1 go_term2 ...
gene_1
gene_2
gene_3
.
.
.
"""
def __init__(self, array, identifiers=None, name='C'):
Dataset.__init__(self, array, identifiers=identifiers, name=name)
def as_spmatrix(self):
if isinstance(self._array, sparse.spmatrix):
return self._array
else:
arr = self.asarray()
return sparse.csr_matrix(arr.astype('i'))
def to_spmatrix(self):
if isinstance(self._array, sparse.spmatrix):
self._array = self._array.tocsr()
else:
self._array = sparse.scr_matrix(self._array)
def as_dictlists(self):
"""Returns data as dict of identifiers along first dim.
ex: data['gene_1'] = ['map0030','map0010', ...]
fixme: Deprecated?
"""
data = {}
for name, ind in self._map[self.get_dim_name(0)].items():
if isinstance(self._array, ndarray):
indices = self._array[ind,:].nonzero()[0]
elif isinstance(self._array, sparse.spmatrix):
if not isinstance(self._array, sparse.csr_matrix):
array = self._array.tocsr()
else:
array = self._array
indices = array[ind,:].indices
if len(indices) == 0: # should we allow categories with no members?
continue
data[name] = self.get_identifiers(self.get_dim_name(1), indices)
self._dictlists = data
return data
def as_selections(self):
"""Returns data as a list of Selection objects.
The list of selections is not ordered (sorted) by any means.
"""
ret_list = []
for cat_name, ind in self._map[self.get_dim_name(1)].items():
if isinstance(self._array, sparse.spmatrix):
if not isinstance(self._array, sparse.csc_matrix):
self._array = self._array.tocsc()
indices = self._array[:,ind].indices
else:
indices = self._array[:,ind].nonzero()[0]
if len(indices) == 0:
continue
ids = self.get_identifiers(self.get_dim_name(0), indices)
selection = Selection(cat_name)
selection.select(self.get_dim_name(0), ids)
ret_list.append(selection)
return ret_list
class GraphDataset(Dataset):
"""The graph dataset class.
A dataset class for representing graphs. The constructor may use an
incidence matrix (possibly sparse) or (if networkx installed) a
networkx.(X)Graph structure.
If the networkx library is installed, there is support for
representing the graph as a networkx.Graph, or networkx.XGraph structure.
"""
def __init__(self, input, identifiers=None, name='A', nodepos = None):
if isinstance(input, sparse.spmatrix):
arr = input
else:
try:
arr = asarray(input)
except:
raise ValueError("Could not identify input")
Dataset.__init__(self, array=arr, identifiers=identifiers, name=name)
self._graph = None
self.nodepos = nodepos
def as_spmatrix(self):
if isinstance(self._array, sparse.spmatrix):
return self._array
else:
arr = self.asarray()
return sparse.csr_matrix(arr.astype('i'))
def to_spmatrix(self):
if isinstance(self._array, sparse.spmatrix):
self._array = self._array.tocsr()
else:
self._array = sparse.scr_matrix(self._array)
def asnetworkx(self):
if self._graph != None:
return self._graph
dim0, dim1 = self.get_dim_name()
node_ids = self.get_identifiers(dim0, sorted=True)
edge_ids = self.get_identifiers(dim1, sorted=True)
G, weights = self._graph_from_incidence_matrix(self._array, node_ids=node_ids, edge_ids=edge_ids)
self._graph = G
return G
def from_networkx(cls, G, node_dim, edge_dim, sp_format=True):
"""Create graph dataset from networkx graph.
When G is a Graph/Digraph edge identifiers will be created,
else (XGraoh/XDigraph) it is assumed that edge attributes are
the edge identifiers.
"""
import networkx as nx
n = G.number_of_nodes()
m = G.number_of_edges()
if isinstance(G, nx.DiGraph):
G = nx.XDiGraph(G)
elif isinstance(G, nx.Graph):
G = nx.XGraph(G)
edge_ids = [e[2] for e in G.edges()]
node_ids = map(str, G.nodes())
n2ind = {}
for ind, node in enumerate(node_ids):
n2ind[node] = ind
if sp_format:
I = sparse.lil_matrix((n, m))
else:
I = zeros((m, n), dtype='i')
for i, (h, t, eid) in enumerate(G.edges()):
if eid != None:
edge_ids[i] = eid
else:
edge_ids[i] = 'e_' + str(i)
hind = n2ind[str(h)]
tind = n2ind[str(t)]
I[hind, i] = 1
if G.is_directed():
I[tind, i] = -1
else:
I[tind, i] = 1
idents = [[node_dim, node_ids], [edge_dim, edge_ids]]
if G.name != '':
name = G.name
else:
name = 'A'
ds = GraphDataset(I, idents, name)
return ds
from_networkx = classmethod(from_networkx)
def _incidence2adjacency(self, I):
"""Incidence to adjacency matrix.
I*I.T - eye(n)?
"""
raise NotImplementedError
def _graph_from_incidence_matrix(self, I, node_ids, edge_ids):
"""Creates a networkx graph class from incidence
(possibly weighted) matrix and ordered labels.
labels = None, results in string-numbered labels
"""
try:
import networkx as nx
except:
print "Failed in import of NetworkX"
return None
m, n = I.shape
assert(m == len(node_ids))
assert(n == len(edge_ids))
weights = []
directed = False
G = nx.XDiGraph(name=self._name)
if isinstance(I, sparse.spmatrix):
I = I.tocsr()
for ename, col in izip(edge_ids, I.T):
if isinstance(I, sparse.spmatrix):
node_ind = col.indices
w1, w2 = col.data
else:
node_ind = where(col != 0)[0]
w1, w2 = col[node_ind]
node1 = node_ids[node_ind[0]]
node2 = node_ids[node_ind[1]]
if w1 < 0: # w1 is tail
directed = True
assert(w2 > 0 and (w1 + w2) == 0)
G.add_edge(node2, node1, ename)
weights.append(w2)
else: #w2 is tail or graph is undirected
assert(w1 > 0)
if w2 < 0:
directed = True
G.add_edge(node1, node2, ename)
weights.append(w1)
if not directed:
G = G.to_undirected()
return G, asarray(weights)
Dataset._all_dims = set()
class ReverseDict(dict):
"""A dictionary which can lookup values by key, and keys by value.
All values and keys must be hashable, and unique.
example:
>>d = ReverseDict((['a',1],['b',2]))
>>print d['a'] --> 1
>>print d.reverse[1] --> 'a'
"""
def __init__(self, *args, **kw):
dict.__init__(self, *args, **kw)
self.reverse = dict([[v, k] for k, v in self.items()])
def __setitem__(self, key, value):
dict.__setitem__(self, key, value)
try:
self.reverse[value] = key
except:
self.reverse = {value:key}
class Selection(dict):
"""Handles selected identifiers along each dimension of a dataset"""
def __init__(self, title='Unnamed Selecton'):
self.title = title
def __getitem__(self, key):
if not self.has_key(key):
return None
return dict.__getitem__(self, key)
def dims(self):
return self.keys()
def axis_len(self, axis):
if self._selection.has_key(axis):
return len(self._selection[axis])
return 0
def select(self, axis, labels):
self[axis] = labels
def write_ftsv(fd, ds, decimals=7, sep='\t', fmt=None, sp_format=True):
"""Writes a dataset in laydi tab separated values (ftsv) form.
@param fd: An open file descriptor to the output file.
@param ds: The dataset to be written.
@param decimals: Number of decimals, only supported for dataset.
@param fmt: String formating
The function handles datasets of these classes:
Dataset, CategoryDataset and GraphDataset
"""
opened = False
if isinstance(fd, str):
fd = open(fd, 'w')
opened = True
# Write header information
if isinstance(ds, CategoryDataset):
type = 'category'
if fmt == None:
fmt = '%d'
elif isinstance(ds, GraphDataset):
type = 'network'
if fmt == None:
fmt = '%d'
elif isinstance(ds, Dataset):
type = 'dataset'
if fmt == None:
fmt = '%%.%df' % decimals
else:
fmt = '%%.%d' %decimals + fmt
else:
raise Exception("Unknown object type")
fd.write('# type: %s' %type + '\n')
for dim in ds.get_dim_name():
fd.write("# dimension: %s" % dim)
for ident in ds.get_identifiers(dim, sorted=True):
fd.write(" " + ident)
fd.write("\n")
fd.write("# name: %s" % ds.get_name() + '\n')
# xy-node-positions
if type == 'network' and ds.nodepos != None:
fd.write("# nodepos:")
node_dim = ds.get_dim_name(0)
for ident in ds.get_identifiers(node_dim, sorted=True):
fd.write(" %s,%s" %ds.nodepos[ident])
fd.write("\n")
# Write data
if hasattr(ds, "as_spmatrix") and sp_format == True:
m = ds.as_spmatrix()
else:
m = ds.asarray()
if isinstance(m, sparse.spmatrix):
_write_sparse_elements(fd, m, fmt, sep)
else:
_write_elements(fd, m, fmt, sep)
if opened:
fd.close()
def read_ftsv(fd, sep=None):
"""Read a dataset in laydi tab separated values (ftsv) form and return it.
@param fd: An open file descriptor.
@return: A Dataset, CategoryDataset or GraphDataset depending on the information
read.
"""
opened = False
if isinstance(fd, str):
fd = open(fd)
opened = True
split_re = re.compile('^#\s*(\w+)\s*:\s*(.+)')
dimensions = []
identifiers = {}
type = 'dataset'
name = 'Unnamed dataset'
sp_format = False
nodepos = None
# graphtype = 'graph'
# Read header lines from file.
line = fd.readline()
while line:
m = split_re.match(line)
if m:
key, val = m.groups()
# The line is on the form;
# dimension: dimname id1 id2 id3 ...
if key == 'dimension':
values = [v.strip() for v in val.split(' ')]
dimensions.append(values[0])
identifiers[values[0]] = values[1:]
# Read type of dataset.
# Should be dataset, category, or network
elif key == 'type':
type = val
elif key == 'name':
name = val
# storage format
# if sp_format is True then use coordinate triplets
elif key == 'sp_format':
if val in ['False', 'false', '0', 'F', 'f',]:
sp_format = False
elif val in ['True', 'true', '1', 'T', 't']:
sp_format = True
else:
raise ValueError("sp_format: %s not valid " %sp_format)
elif key == 'nodepos':
node_dim = dimensions[0]
idents = identifiers[node_dim]
nodepos = {}
xys = val.split(" ")
for node_id, xy in zip(idents, xys):
x, y = map(float, xy.split(","))
nodepos[node_id] = (x, y)
else:
break
line = fd.readline()
# Dimensions in the form [(dim1, [id1, id2, id3 ..) ...]
dims = [(x, identifiers[x]) for x in dimensions]
dim_lengths = [len(identifiers[x]) for x in dimensions]
# Create matrix and assign element reader
if type == 'category':
if sp_format:
matrix = sparse.lil_matrix(dim_lengths)
else:
matrix = empty(dim_lengths, dtype='i')
else:
if sp_format:
matrix = sparse.lil_matrix(dim_lengths)
else:
matrix = empty(dim_lengths)
if sp_format:
matrix = _read_sparse_elements(fd, matrix)
else:
matrix = _read_elements(fd, matrix)
# Create dataset of specified type
if type == 'category':
ds = CategoryDataset(matrix, dims, name)
elif type == 'network':
ds = GraphDataset(matrix, dims, name=name, nodepos=nodepos)
else:
ds = Dataset(matrix, dims, name)
if opened:
fd.close()
return ds
def write_csv(fd, ds, decimals=7, sep='\t'):
"""Write a dataset as comma/tab/whatever dilimited data.
@param fd: An open file descriptor to the output file.
@param ds: The dataset to be written.
@param decimals: Number of decimals, only supported for dataset.
@param sep: Value separator
"""
## Open file if a string is passed instead of a file descriptor
opened = False
if isinstance(fd, str):
fd = open(fd, 'w')
opened = True
## Get data
rowdim, coldim = ds.get_dim_name()
rowids = ds.get_identifiers(rowdim)
colids = ds.get_identifiers(coldim)
a = ds.asarray()
y, x = a.shape
fmt = '%%%if' % decimals
## Write header
fd.write(rowdim)
fd.write(sep)
for i, id in enumerate(colids):
fd.write(id)
fd.write(sep)
fd.write('\n')
## Write matrix data
for j in range(y):
fd.write(rowids[j])
fd.write(sep)
for i in range(x):
fd.write(fmt % (a[j, i],))
fd.write(sep)
fd.write('\n')
## If we opened the stream, close it
if opened:
fd.close()
def _write_sparse_elements(fd, arr, fmt='%d', sep=None):
""" Sparse coordinate format."""
fd.write('# sp_format: True\n\n')
fmt = '%d %d ' + fmt + '\n'
csr = arr.tocsr()
for ii in xrange(csr.size):
ir, ic = csr.rowcol(ii)
data = csr.getdata(ii)
fd.write(fmt % (ir, ic, data))
def _write_elements(fd, arr, fmt='%f', sep='\t'):
"""Standard value separated format."""
fmt = fmt + sep
fd.write('\n')
y, x = arr.shape
for j in range(y):
for i in range(x):
fd.write(fmt %arr[j, i])
fd.write('\n')
def _read_elements(fd, arr, sep=None):
line = fd.readline()
i = 0
while line:
values = line.split(sep)
for j, val in enumerate(values):
arr[i,j] = float(val)
i += 1
line = fd.readline()
return arr
def _read_sparse_elements(fd, arr, sep=None):
line = fd.readline()
while line:
i, j, val = line.split()
arr[int(i),int(j)] = float(val)
line = fd.readline()
return arr.tocsr()

View File

@ -1,401 +0,0 @@
#!/usr/bin/python
import os
import sys
import pygtk
pygtk.require('2.0')
import gobject
import gtk
import gtk.gdk
import gtk.glade
import gnome
import gnome.ui
import scipy
import pango
import projectview, workflow, dataset, view, navigator, dialogs, selections, plots, main
from logger import logger, LogView
PROGRAM_NAME = 'laydi'
VERSION = '0.1.0'
DATADIR = os.path.join(main.PYDIR, 'laydi')
#ICONDIR = os.path.join(DATADIR,"..","icons")
ICONDIR = main.ICONDIR
GLADEFILENAME = os.path.join(main.PYDIR, 'laydi/laydi.glade')
_icon_mapper = {dataset.Dataset: 'dataset',
dataset.CategoryDataset: 'category_dataset',
dataset.GraphDataset: 'graph_dataset',
plots.Plot: 'line_plot'}
class IconFactory:
"""Factory for icons that ensures that each icon is only loaded once."""
def __init__(self, path):
self._path = path
self._icons = {}
def get(self, iconname):
"""Returns the gdk loaded PixBuf for the given icon.
Reads the icon from file if necessary."""
# if iconname isnt a string, try to autoconvert
if not isinstance(iconname, str):
for cls in _icon_mapper.keys():
if isinstance(iconname, cls):
iconname = _icon_mapper[cls]
if self._icons.has_key(iconname):
return self._icons[iconname]
icon_fname = os.path.join(self._path, '%s.png' % iconname)
icon = gtk.gdk.pixbuf_new_from_file(icon_fname)
self._icons[iconname] = icon
return icon
icon_factory = IconFactory(ICONDIR)
class TableSizeSelection(gtk.Window):
def __init__(self):
self._SIZE = size = 5
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
self._table = gtk.Table(size, size, True)
self._items = []
## Create a 3x3 table of EventBox object, doubly stored because
## gtk.Table does not support indexed retrieval.
for y in range(size):
line = []
for x in range(size):
ebox = gtk.EventBox()
ebox.add(gtk.Frame())
ebox.set_size_request(20, 20)
ebox.set_visible_window(True)
self._table.attach(ebox, x, x+1, y, y+1, gtk.FILL, gtk.FILL)
line.append(ebox)
self._items.append(line)
self.set_border_width(5)
self.add(self._table)
self.connect_signals()
def _get_child_pos(self, child):
size = self._SIZE
for x in range(size):
for y in range(size):
if self._items[y][x] == child:
return (x, y)
return None
def connect_signals(self):
size = self._SIZE
for x in range(size):
for y in range(size):
self._items[y][x].add_events(gtk.gdk.ENTER_NOTIFY_MASK)
self._items[y][x].connect("enter-notify-event",
self._on_enter_notify)
self._items[y][x].connect("button-release-event",
self._on_button_release)
def _on_enter_notify(self, widget, event):
size = self._SIZE
x, y = self._get_child_pos(widget)
for i in range(size):
for j in range(size):
if i <= x and j <= y:
self._items[j][i].set_state(gtk.STATE_SELECTED)
else:
self._items[j][i].set_state(gtk.STATE_NORMAL)
self.x = x
self.y = y
def _on_button_release(self, widget, event):
size = self._SIZE
self.emit('table-size-set', self.x+1, self.y+1)
self.hide_all()
for x in range(size):
for y in range(size):
self._items[y][x].set_state(gtk.STATE_NORMAL)
class ViewFrameToolButton (gtk.ToolItem):
def __init__(self):
gtk.ToolItem.__init__(self)
fname = os.path.join(ICONDIR, "table_size.png")
image = gtk.Image()
image.set_from_file(fname)
self._button = gtk.Button()
self._button.set_image(image)
self._button.set_property("can-focus", False)
eb = gtk.EventBox()
eb.add(self._button)
self.add(eb)
self._item = TableSizeSelection()
self._button.connect("button-press-event", self._on_show_menu)
image.show()
self._image = image
self._item.connect("table-size-set", self._on_table_size_set)
self._button.set_relief(gtk.RELIEF_NONE)
self.show_all()
def _on_show_menu(self, widget, event):
x, y = self._image.window.get_origin()
x2, y2, w, h, b = self._image.window.get_geometry()
self._item.move(x, y+h)
self._item.show_all()
def _on_table_size_set(self, widget, width, height):
main.application['main_view'].resize_table(width, height)
class LaydiApp:
def __init__(self): # Application variables
self.current_data = None
self._last_view = None
self._plot_toolbar = None
self._toolbar_state = None
gtk.glade.set_custom_handler(self.custom_object_factory)
self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'appwindow')
# self.workflow = wf
self.idlist_crt = selections.IdListController(self['identifier_list'])
self.sellist_crt = selections.SelectionListController(self['selection_tree'],
self.idlist_crt)
self.dimlist_crt = selections.DimListController(self['dim_list'],
self.sellist_crt)
self.sellist_crt.set_dimlist_controller(self.dimlist_crt)
def init_gui(self):
self['appwindow'].set_size_request(800, 600)
# Set up workflow
self.wf_view = workflow.WorkflowView(main.workflow)
self.wf_view.show()
self['workflow_vbox'].pack_end(self.wf_view)
self._wf_menu = workflow.WorkflowMenu(main.workflow)
self._wf_menu.show()
wf_menuitem = gtk.MenuItem('Fu_nctions')
wf_menuitem.set_submenu(self._wf_menu)
wf_menuitem.show()
self['menubar1'].insert(wf_menuitem, 2)
# Connect signals
signals = {'on_quit1_activate' : (gtk.main_quit),
'on_appwindow_delete_event' : (gtk.main_quit),
'on_zoom_in_button_clicked' : (self.on_single_view),
'on_zoom_out_button_clicked' : (self.on_multiple_view),
'on_new1_activate' : (self.on_create_project),
'on_button_new_clicked' : (self.on_create_project),
'on_workflow_refresh_clicked' : (self.on_workflow_refresh_clicked),
'on_index1_activate' : (self.on_help_index),
'on_about1_activate' : (self.on_help_about),
'on_report_bug1_activate' : (self.on_help_report_bug),
'on_small_view1_activate' : (self.on_multiple_view),
'on_large_view1_activate' : (self.on_single_view),
'on_left1_activate' : (self.on_left),
'on_right1_activate' : (self.on_right),
'on_up1_activate' : (self.on_up),
'on_down1_activate' : (self.on_down),
'on_navigator1_activate' : (self.on_show_navigator),
'on_workflow1_activate' : (self.on_show_workflow),
'on_information1_activate' : (self.on_show_infopane),
}
self.widget_tree.signal_autoconnect(signals)
self['main_view'].connect('view-changed', self.on_view_changed)
# Log that we've set up the app now
logger.debug('Program started')
# Add ViewFrame table size to toolbar
tb = ViewFrameToolButton()
self['toolbar'].add(tb)
def set_projectview(self, proj):
logger.notice('Welcome to your new project. Grasp That Data!')
self.navigator_view.add_projectview(proj)
self.dimlist_crt.set_projectview(proj)
self.sellist_crt.set_projectview(proj)
def set_workflow(self, workflow):
main.workflow = workflow
self.wf_view.set_workflow(main.workflow)
def show(self):
self.init_gui()
def change_plot(self, plot):
"""Sets the plot in the currently active ViewFrame. If the plot is
already shown in another ViewFrame it will be moved from there."""
# Set current selection in the plot before showing it.
plot.selection_changed(None, main.projectview.get_selection())
self['main_view'].insert_view(plot)
self._update_toolbar(plot)
def change_plots(self, plots):
"""Changes all plots."""
self['main_view'].set_all_plots(plots)
v = self.get_active_view_frame().get_view()
self._update_toolbar(v)
def get_active_view_frame(self):
return self['main_view'].get_active_view_frame()
def _update_toolbar(self, view):
"""Set the plot specific toolbar to the toolbar of the currently
active plot."""
# don't do anything on no change
if self._last_view == view:
return
self._last_view = view
logger.debug("view changed to %s" % view)
window = self['plot_toolbar_dock']
if self._plot_toolbar:
toolbar_state = self._plot_toolbar.get_mode()
window.remove(self._plot_toolbar)
else:
toolbar_state = "default"
if view:
self._plot_toolbar = view.get_toolbar()
self._plot_toolbar.set_mode(toolbar_state)
else:
self._plot_toolbar = None
if self._plot_toolbar:
window.add(self._plot_toolbar)
# Methods to create GUI widgets from CustomWidgets in the glade file.
# The custom_object_factory calls other functions to generate specific
# widgets.
def custom_object_factory(self, glade, fun_name, widget_name, s1, s2, i1, i2):
"Called by the glade file reader to create custom GUI widgets."
handler = getattr(self, fun_name)
return handler(s1, s2, i1, i2)
def create_logview(self, str1, str2, int1, int2):
self.log_view = LogView(logger)
self.log_view.show()
return self.log_view
def create_main_view(self, str1, str2, int1, int2):
self.main_view = view.MainView()
self.main_view.show()
return self.main_view
def create_navigator_view(self, str1, str2, int1, int2):
self.navigator_view = navigator.NavigatorView()
self.navigator_view.show()
return self.navigator_view
def create_dim_list(self, str1, str2, int1, int2):
self.dim_list = selections.DimList()
self.dim_list.show()
return self.dim_list
def create_selection_tree(self, str1, str2, int1, int2):
self.selection_tree = selections.SelectionTree()
self.selection_tree.show()
return self.selection_tree
def create_identifier_list(self, str1, str2, int1, int2):
self.identifier_list = selections.IdentifierList()
self.identifier_list.show()
return self.identifier_list
def __getitem__(self, key):
return self.widget_tree.get_widget(key)
# Event handlers.
# These methods are called by the gtk framework in response to events and
# should not be called directly.
def on_single_view(self, *ignored):
self['main_view'].goto_large()
def on_multiple_view(self, *ignored):
self['main_view'].goto_small()
def on_create_project(self, *rest):
d = dialogs.CreateProjectDruid(self)
d.run()
def on_help_about(self, *rest):
widget_tree = gtk.glade.XML(GLADEFILENAME, 'aboutdialog')
about = widget_tree.get_widget('aboutdialog')
about.run()
def on_help_index(self, *ignored):
gnome.help_display_uri('https://dev.pvv.org/projects/laydi/wiki/help')
def on_help_report_bug(self, *ignored):
gnome.help_display_uri('https://dev.pvv.org/projects/laydi/newticket')
def on_workflow_refresh_clicked(self, *ignored):
try:
reload(sys.modules[main.workflow.__class__.__module__])
except Exception, e:
logger.warning('Cannot reload workflow')
logger.warning(e)
else:
logger.notice('Successfully reloaded workflow')
def on_view_changed(self, widget, vf):
self._update_toolbar(vf.get_view())
def on_show_navigator(self, item):
if item.get_active():
self['data_vbox'].show()
else:
self['data_vbox'].hide()
def on_show_workflow(self, item):
if item.get_active():
self['workflow_vbox'].show()
else:
self['workflow_vbox'].hide()
def on_show_infopane(self, item):
if item.get_active():
self['bottom_notebook'].show()
else:
self['bottom_notebook'].hide()
def on_left(self, item):
self.main_view.move_focus_left()
def on_right(self, item):
self.main_view.move_focus_right()
def on_up(self, item):
self.main_view.move_focus_up()
def on_down(self, item):
self.main_view.move_focus_down()
gobject.signal_new('table-size-set', TableSizeSelection,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_INT, gobject.TYPE_INT))

View File

@ -1,284 +0,0 @@
"""A collection of functions that use R.
Most functions use libraries from bioconductor
depends on:
(not updated)
-- bioconductor min. install
-- hgu133a
-- hgu133plus2
"""
import scipy
import Numeric as N
import rpy
silent_eval = rpy.with_mode(rpy.NO_CONVERSION, rpy.r)
def get_locusid(probelist=None,org="hgu133a"):
"""Returns a dictionary of locus link id for each affy probeset
and reverse mapping
innput:
[probelist] -- probelist of affy probesets
[org] -- chip type (organism)
out:
aff2loc, loc2aff
The mapping is one-to-one for affy->locus_id
However, there are several affy probesets for one locus_id
From bioc-mail-archive: BioC takes the GeneBank ids associated
with the probes (provided by the manufacture) and then maps them
to Entrez Gene ids using data from UniGene, Entrez Gene, and other
available data sources we trust. The Entrez Gene id a probe is
assigned to is determined by votes from all the sources used. If
there is no agreement among the sources, we take the smallest
Entrez Gene id.
"""
silent_eval("library("+org+")")
silent_eval('locus_ids = as.list('+org+'LOCUSID)')
silent_eval('pp<-as.list(locus_ids[!is.na(locus_ids)])')
loc_ids = rpy.r("pp")
for id in loc_ids:
loc_ids[id] = str(loc_ids[id])
aff2loc = {}
if probelist:
for pid in probelist:
try:
aff2loc[pid]=loc_ids[pid]
except:
print "Affy probeset: %s has no locus id" %pid
print "\nCONVERSION SUMMARY:\n \
Number of probesets input %s \n \
Number of translated locus ids: %s \n \
Number of missings: %s" %(len(probelist),len(aff2loc),len(probelist)-len(aff2loc))
else:
aff2loc = loc_ids
# reverse mapping
loc2aff = {}
for k,v in aff2loc.items():
if loc2aff.has_key(v):
loc2aff[v].append(k)
else:
loc2aff[v]=[k]
return aff2loc,loc2aff
def get_kegg_paths(org="hgu133plus2",id_type='aff',probelist=None):
"""Returns a dictionary of KEGG maps.
input:
org -- chip_type (see bioconductor.org)
id_type -- id ['aff','loc']
key: affy_id, value = list of kegg map id
example: '65884_at': ['00510', '00513']
"""
silent_eval("library("+org+")")
silent_eval('xx<-as.list('+org+'PATH)')
silent_eval('xp <- xx[!is.na(xx)]')
aff2path = rpy.r("xp")
dummy = rpy.r("xx")
if id_type=='loc':
aff2loc,loc2aff = get_locusid(org=org)
loc2path = {}
for id,path in aff2path.items():
if loc2path.has_key(id):
pp = [path.append(i) for i in loc2path[id]]
print "Found duplicate in path: %s" %path
loc2path[aff2loc[id]]=path
aff2path = loc2path
out = {}
if probelist:
for pid in probelist:
try:
out[pid]=aff2path[pid]
except:
print "Could not find id: %s" %pid
else:
out = aff2path
for k,v in out.items():
# if string convert tol list
try:
v + ''
out[k] = [v]
except:
out[k] = v
return out
def get_probe_list(org="hgu133plus2"):
rpy.r.library(org)
silent_eval('probe_list<-ls('+org+'ACCNUM )')
pl = rpy.r("probe_list")
return pl
def get_GO_from_aff(org="hgu133plus2",id_type='aff',probelist=None):
"""Returns a dictionary of GO terms.
input:
org -- chip_type (see bioconductor.org)
id_type -- id ['aff','loc']
key:
example: '65884_at':
"""
silent_eval("library("+org+")")
silent_eval('xx<-as.list('+org+'GO)')
silent_eval('xp <- xx[!is.na(xx)]')
aff2path = rpy.r("xp")
dummy = rpy.r("xx")
if id_type=='loc':
LOC = get_locusid(org=org)
loc2path = {}
for id,path in aff2path.items():
if loc2path.has_key(id):
pp = [path.append(i) for i in loc2path[id]]
print "Found duplicate in path: %s" %path
loc2path[LOC[id]]=path
aff2path = loc2path
out = {}
if probelist:
for pid in probelist:
try:
out[pid]=aff2path[pid]
except:
print "Could not find id: %s" %pid
return aff2path
def get_kegg_as_category(org="hgu133plus2",id_type='aff',probelist=None):
"""Returns kegg pathway memberships in dummy (1/0) matrix (genes x maps)
"""
kegg = get_kegg_paths(org=org, id_type=id_type, probelist=probelist)
maps = set()
for kpth in kegg.values():
maps.update(kpth)
n_maps = len(maps)
n_genes = len(kegg)
gene2index = dict(zip(kegg.keys(), range(n_genes)))
map2index = dict(zip(maps, range(n_maps)))
C = scipy.zeros((n_genes, n_maps))
for k,v in kegg.items():
for m in v:
C[gene2index[k], map2index[m]]=1
return C, list(maps), kegg.keys()
def impute(X, k=10, rowmax=0.5, colmax=0.8, maxp=1500, seed=362436069):
"""
A function to impute missing expression data, using nearest
neighbor averaging. (from bioconductors impute)
input:
data: An expression matrix with genes in the rows, samples in the
columns
k: Number of neighbors to be used in the imputation (default=10)
rowmax: The maximum percent missing data allowed in any row (default
50%). For any rows with more than 'rowmax'% missing are
imputed using the overall mean per sample.
colmax: The maximum percent missing data allowed in any column
(default 80%). If any column has more than 'colmax'% missing
data, the program halts and reports an error.
maxp: The largest block of genes imputed using the knn algorithm
inside 'impute.knn' (default 1500); larger blocks are divided
by two-means clustering (recursively) prior to imputation. If
'maxp=p', only knn imputation is done
seed: The seed used for the random number generator (default
362436069) for reproducibility.
call:
impute(data ,k = 10, rowmax = 0.5, colmax = 0.8, maxp = 1500, rng.seed=362436069)
"""
rpy.r.library("impute")
X = N.asarray(X) # cast as numeric array
m, n = scipy.shape(X)
if m>n:
print "Warning (impute): more samples than variables. running transpose"
t_flag = True
else:
X = N.transpose(X)
t_flag = False
rpy.r.assign("X", X)
rpy.r.assign("k", k)
rpy.r.assign("rmax", rowmax)
rpy.r.assign("cmax", colmax)
rpy.r.assign("maxp", maxp)
call = "out<-impute.knn(X,k=k,rowmax=rmax,colmax=cmax,maxp=maxp)"
silent_eval(call)
out = rpy.r("out")
if not t_flag:
E = out['data']
E = scipy.asarray(E)
E = E.T
else:
E = out['data']
E = scipy.asarray(E)
return E
def get_chip_annotation(org="hgu133a",annot='pmid', id_type='loc',probelist=None):
"""Returns a dictionary of annoations.
input:
org -- chip_type (see bioconductor.org)
annot -- annotation ['genename', 'pmid', ' symbol']
id_type -- id ['aff','loc']
key: id, value = list of annoations
example: '65884_at': ['15672394', '138402']
"""
_valid_annot = ['genename', 'pmid', 'symbol', 'enzyme', 'chr', 'chrloc']
if annot.lower() not in _valid_annot:
raise ValueError("Annotation must be one of %s" %_valid_annot)
silent_eval("library("+org+")")
silent_eval("dummy<-as.list("+org+annot.upper()+")")
silent_eval('annotations <- dummy[!is.na(dummy)]')
aff2annot = rpy.r("annotations")
if id_type=='loc':
aff2loc, loc2aff = get_locusid(org=org)
loc2annot = {}
for geneid, annotation in aff2annot.items():
annotation = ensure_list(annotation)
print annotation
if loc2annot.has_key(geneid):
for extra in loc2annot[geneid]:
annotation.append(extra)
print "Found duplicate in gene: %s" %geneid
loc2annot[aff2loc[geneid]] = annotation
aff2annot = loc2annot
out = {}
if probelist:
for pid in probelist:
try:
out[pid] = aff2annot.get(pid, 'none')
except:
print "Could not find id: %s" %pid
else:
out = aff2annot
return out
def ensure_list(value):
if isinstance(value, list):
return value
else:
return [value]

File diff suppressed because it is too large Load Diff

View File

@ -1,458 +0,0 @@
"""Specialised plots for functions defined in blmfuncs.py.
fixme:
-- If scatterplot is not inited with a colorvector there will be no
colorbar, but when adding colors the colorbar shoud be created.
"""
from matplotlib import cm,patches
import gtk
import laydi
from laydi import plots, main,logger
import scipy
from scipy import dot,sum,diag,arange,log,newaxis,sqrt,apply_along_axis,empty
from numpy import corrcoef
def correlation_loadings(data, T, test=True):
""" Returns correlation loadings.
:input:
- D: [nsamps, nvars], data (non-centered data)
- T: [nsamps, a_max], Scores
:ouput:
- R: [nvars, a_max], Correlation loadings
:notes:
"""
nsamps, nvars = data.shape
nsampsT, a_max = T.shape
if nsamps!=nsampsT: raise IOError("D/T mismatch")
# center
data = data - data.mean(0)
R = empty((nvars, a_max),'d')
for a in range(a_max):
for k in range(nvars):
R[k,a] = corrcoef(data[:,k], T[:,a])[0,1]
return R
class BlmScatterPlot(plots.ScatterPlot):
"""Scatter plot used for scores and loadings in bilinear models."""
def __init__(self, title, model, absi=0, ordi=1, part_name='T', color_by=None):
self.model = model
if model.model.has_key(part_name)!=True:
raise ValueError("Model part: %s not found in model" %mod_param)
self._T = model.model[part_name]
if self._T.shape[1]==1:
logger.log('notice', 'Scores have only one component')
absi= ordi = 0
self._absi = absi
self._ordi = ordi
self._cmap = cm.summer
dataset_1 = model.as_dataset(part_name)
id_dim = dataset_1.get_dim_name(0)
sel_dim = dataset_1.get_dim_name(1)
id_1, = dataset_1.get_identifiers(sel_dim, [absi])
id_2, = dataset_1.get_identifiers(sel_dim, [ordi])
col = 'b'
if model.model.has_key(color_by):
col = model.model[color_by].ravel()
plots.ScatterPlot.__init__(self, dataset_1, dataset_1, id_dim, sel_dim, id_1, id_2 ,c=col ,s=40 , name=title)
self._mappable.set_cmap(self._cmap)
self.sc = self._mappable
self.add_pc_spin_buttons(self._T.shape[1], absi, ordi)
def set_facecolor(self, colors):
"""Set patch facecolors.
"""
pass
def set_alphas(self, alphas):
"""Set alpha channel for all patches."""
pass
def set_sizes(self, sizes):
"""Set patch sizes."""
pass
def set_expvar_axlabels(self, param=None):
if param == None:
param = self._expvar_param
else:
self._expvar_param = param
if not self.model.model.has_key(param):
self.model.model[param] = None
if self.model.model[param]==None:
logger.log('notice', 'Param: %s not in model' %param)
print self.model.model.keys()
print self.model.model[param]
pass #fixme: do expvar calc here if not present
else:
expvar = self.model.model[param]
xstr = "Comp: %s , %.1f " %(self._absi, expvar[self._absi+1])
ystr = "Comp: %s , %.1f " %(self._ordi, expvar[self._ordi+1])
self.axes.set_xlabel(xstr)
self.axes.set_ylabel(ystr)
def add_pc_spin_buttons(self, amax, absi, ordi):
sb_a = gtk.SpinButton(climb_rate=1)
sb_a.set_range(1, amax)
sb_a.set_value(absi+1)
sb_a.set_increments(1, 5)
sb_a.connect('value_changed', self.set_absicca)
sb_o = gtk.SpinButton(climb_rate=1)
sb_o.set_range(1, amax)
sb_o.set_value(ordi+1)
sb_o.set_increments(1, 5)
sb_o.connect('value_changed', self.set_ordinate)
hbox = gtk.HBox()
gtk_label_a = gtk.Label("A:")
gtk_label_o = gtk.Label(" O:")
toolitem = gtk.ToolItem()
toolitem.set_expand(False)
toolitem.set_border_width(2)
toolitem.add(hbox)
hbox.pack_start(gtk_label_a)
hbox.pack_start(sb_a)
hbox.pack_start(gtk_label_o)
hbox.pack_start(sb_o)
self._toolbar.insert(toolitem, -1)
toolitem.set_tooltip(self._toolbar.tooltips, "Set Principal component")
self._toolbar.show_all() #do i need this?
def set_absicca(self, sb):
self._absi = sb.get_value_as_int() - 1
xy = self._T[:,[self._absi, self._ordi]]
self.xaxis_data = xy[:,0]
self.yaxis_data = xy[:,1]
self.sc._offsets = xy
self.selection_collection._offsets = xy
self.canvas.draw_idle()
pad = abs(self.xaxis_data.min()-self.xaxis_data.max())*0.05
new_lims = (self.xaxis_data.min() - pad, self.xaxis_data.max() + pad)
self.axes.set_xlim(new_lims, emit=True)
self.set_expvar_axlabels()
self.canvas.draw_idle()
def set_ordinate(self, sb):
self._ordi = sb.get_value_as_int() - 1
xy = self._T[:,[self._absi, self._ordi]]
self.xaxis_data = xy[:,0]
self.yaxis_data = xy[:,1]
self.sc._offsets = xy
self.selection_collection._offsets = xy
pad = abs(self.yaxis_data.min()-self.yaxis_data.max())*0.05
new_lims = (self.yaxis_data.min() - pad, self.yaxis_data.max() + pad)
self.axes.set_ylim(new_lims, emit=True)
self.set_expvar_axlabels()
self.canvas.draw_idle()
def show_labels(self, index=None):
if self._text_labels == None:
x = self.xaxis_data
y = self.yaxis_data
self._text_labels = {}
for name, n in self.dataset_1[self.current_dim].items():
txt = self.axes.text(x[n],y[n], name)
txt.set_visible(False)
self._text_labels[n] = txt
if index!=None:
self.hide_labels()
for indx,txt in self._text_labels.items():
if indx in index:
txt.set_visible(True)
self.canvas.draw_idle()
def hide_labels(self):
for txt in self._text_labels.values():
txt.set_visible(False)
self.canvas.draw_idle()
class PcaScreePlot(plots.BarPlot):
def __init__(self, model):
title = "Pca, (%s) Scree" %model._dataset['X'].get_name()
ds = model.as_dataset('eigvals')
if ds==None:
logger.log('notice', 'Model does not contain eigvals')
plots.BarPlot.__init__(self, ds, name=title)
class PcaScorePlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Pca scores (%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, 'T')
self.set_expvar_axlabels(param="expvarx")
class PcaLoadingPlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Pca loadings (%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='P', color_by='p_tsq')
self.set_expvar_axlabels(param="expvarx")
class PlsScorePlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Pls scores (%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, 'T')
class PlsXLoadingPlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Pls x-loadings (%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='P', color_by='w_tsq')
#self.set_expvar_axlabels(self, param="expvarx")
class PlsYLoadingPlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Pls y-loadings (%s)" %model._dataset['Y'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='Q')
class PlsCorrelationLoadingPlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Pls correlation loadings (%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='CP')
class LplsScorePlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "L-pls scores (%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, 'T')
self.set_expvar_axlabels("evx")
class LplsXLoadingPlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Lpls x-loadings (%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='P', color_by='tsqx')
self.set_expvar_axlabels("evx")
class LplsZLoadingPlot(BlmScatterPlot, plots.PlotThresholder):
def __init__(self, model, absi=0, ordi=1):
title = "Lpls z-loadings (%s)" %model._dataset['Z'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='L', color_by='tsqz')
self.set_expvar_axlabels(param="evz")
plots.PlotThresholder.__init__(self, "IC")
def _update_color_from_dataset(self, ds):
BlmScatterPlot._update_color_from_dataset(self, ds)
self.set_threshold_dataset(ds)
class LplsXCorrelationPlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Lpls x-corr. loads (%s)" %model._dataset['X'].get_name()
if not model.model.has_key('Rx'):
R = correlation_loadings(model._data['X'], model.model['T'])
model.model['Rx'] = R
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='Rx')
self.set_expvar_axlabels("evx")
radius = 1
center = (0,0)
c100 = patches.Circle(center,radius=radius,
facecolor='gray',
alpha=.1,
zorder=1)
c50 = patches.Circle(center, radius= sqrt(radius/2.0),
facecolor='gray',
alpha=.1,
zorder=2)
self.axes.add_patch(c100)
self.axes.add_patch(c50)
self.axes.axhline(lw=1.5,color='k')
self.axes.axvline(lw=1.5,color='k')
self.axes.set_xlim([-1.05,1.05])
self.axes.set_ylim([-1.05, 1.05])
self.canvas.show()
class LplsZCorrelationPlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Lpls z-corr. loads (%s)" %model._dataset['Z'].get_name()
if not model.model.has_key('Rz'):
R = correlation_loadings(model._data['Z'].T, model.model['W'])
model.model['Rz'] = R
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='Rz')
self.set_expvar_axlabels("evz")
radius = 1
center = (0,0)
c100 = patches.Circle(center,radius=radius,
facecolor='gray',
alpha=.1,
zorder=1)
c50 = patches.Circle(center, radius=sqrt(radius/2.0),
facecolor='gray',
alpha=.1,
zorder=2)
self.axes.add_patch(c100)
self.axes.add_patch(c50)
self.axes.axhline(lw=1.5,color='k')
self.axes.axvline(lw=1.5,color='k')
self.axes.set_xlim([-1.05,1.05])
self.axes.set_ylim([-1.05, 1.05])
self.canvas.show()
class LplsHypoidCorrelationPlot(BlmScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Hypoid correlations(%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, part_name='W')
class LplsExplainedVariancePlot(plots.Plot):
def __init__(self, model):
self.model = model
plots.Plot.__init__(self, "Explained variance")
xax = scipy.arange(model.model['evx'].shape[0])
self.axes.plot(xax, model.model['evx'], 'b-', label='X', linewidth=1.5)
self.axes.plot(xax, model.model['evy'], 'k-', label='Y', linewidth=1.5)
self.axes.plot(xax, model.model['evz'], 'g-', label='Z', linewidth=1.5)
self.canvas.draw()
class LineViewXc(plots.LineViewPlot):
"""A line view of centered raw data
"""
def __init__(self, model, name='Profiles'):
dx = model._dataset['X']
plots.LineViewPlot.__init__(self, dx, 1, None, False,name)
self.add_center_check_button(self.data_is_centered)
def add_center_check_button(self, ticked):
"""Add a checker button for centerd view of data."""
cb = gtk.CheckButton("Center")
cb.set_active(ticked)
cb.connect('toggled', self._toggle_center)
toolitem = gtk.ToolItem()
toolitem.set_expand(False)
toolitem.set_border_width(2)
toolitem.add(cb)
self._toolbar.insert(toolitem, -1)
toolitem.set_tooltip(self._toolbar.tooltips, "Column center the line view")
self._toolbar.show_all() #do i need this?
def _toggle_center(self, active):
if self.data_is_centered:
self._data = self._data + self._mn_data
self.data_is_centered = False
else:
self._mn_data = self._data.mean(0)
self._data = self._data - self._mn_data
self.data_is_centered = True
self.make_lines()
self.set_background()
self.set_current_selection(main.project.get_selection())
class ParalellCoordinates(plots.Plot):
"""Parallell coordinates for score loads with many comp.
"""
def __init__(self, model, p='loads'):
pass
class PlsQvalScatter(plots.ScatterPlot):
"""A vulcano like plot of loads vs qvals
"""
def __init__(self, model, pc=0):
if not model.model.has_key('w_tsq'):
return None
self._W = model.model['W']
dataset_1 = model.as_dataset('W')
dataset_2 = model.as_dataset('w_tsq')
id_dim = dataset_1.get_dim_name(0) #genes
sel_dim = dataset_1.get_dim_name(1) #_comp
sel_dim_2 = dataset_2.get_dim_name(1) #_zero_dim
id_1, = dataset_1.get_identifiers(sel_dim, [0])
id_2, = dataset_2.get_identifiers(sel_dim_2, [0])
if model.model.has_key('w_tsq'):
col = model.model['w_tsq'].ravel()
#col = normalise(col)
else:
col = 'g'
plots.ScatterPlot.__init__(self, dataset_1, dataset_2,
id_dim, sel_dim, id_1, id_2,
c=col, s=20, sel_dim_2=sel_dim_2,
name='Load Volcano')
class PredictionErrorPlot(plots.Plot):
"""A boxplot of prediction error vs. comp. number.
"""
def __init__(self, model, name="Prediction Error"):
if not model.model.has_key('sep'):
logger.log('notice', 'Model has no calculations of sep')
return None
plots.Plot.__init__(self, name)
self._frozen = True
self.current_dim = 'johndoe'
self.axes = self.fig.add_subplot(111)
# draw
sep = model.model['sep']
aopt = model.model['aopt']
bx_plot_lines = self.axes.boxplot(sqrt(sep))
aopt_marker = self.axes.axvline(aopt, linewidth=10,
color='r',zorder=0,
alpha=.5)
# add canvas
self.add(self.canvas)
self.canvas.show()
def set_current_selection(self, selection):
pass
class TRBiplot(plots.ScatterPlot):
def __init__(self, model, absi=0, ordi=1):
title = "Target rotation biplot(%s)" %model._dataset['X'].get_name()
BlmScatterPlot.__init__(self, title, model, absi, ordi, 'B')
B = model.model.get('B')
# normalize B
Bnorm = scipy.apply_along_axis(scipy.linalg.norm, 1, B)
x = model._dataset['X'].copy()
Xc = x._array - x._array.mean(0)[newaxis]
w_rot = B/Bnorm
t_rot = dot(Xc, w_rot)
class InfluencePlot(plots.ScatterPlot):
""" Returns a leverage vs resiudal scatter plot.
"""
def __init__(self, model, dim, name="Influence"):
if not model.model.has_key('levx'):
logger.log('notice', 'Model has no calculations of leverages')
return
if not model.model.has_key('ssqx'):
logger.log('notice', 'Model has no calculations of residuals')
return
ds1 = model.as_dataset('levx')
ds2 = model.as_dataset('ssqx')
plots.ScatterPlot.__init__(self, ds1, ds2,
id_dim, sel_dim, id_1, id_2,
c=col, s=20, sel_dim_2=sel_dim_2,
name='Load Volcano')
class RMSEPPlot(plots.BarPlot):
def __init__(self, model, name="RMSEP"):
if not model.model.has_key('rmsep'):
logger.log('notice', 'Model has no calculations of sep')
return
dataset = model.as_dataset('rmsep')
plots.BarPlot.__init__(self, dataset, name=name)
def normalise(x):
"""Scale vector x to [0,1]
"""
x = x - x.min()
x = x/x.max()
return x

View File

@ -1,66 +0,0 @@
from numpy import array_split,arange
def cv(n, k, randomise=False, sequential=False):
"""
Generates k (training, validation) index pairs.
Each pair is a partition of arange(n), where validation is an iterable
of length ~n/k.
If randomise is true, a copy of index is shuffled before partitioning,
otherwise its order is preserved in training and validation.
Randomise overrides the sequential argument. If randomise is true,
sequential is False
If sequential is true the index is partioned in continous blocks,
otherwise interleaved ordering is used.
"""
index = xrange(N)
if randomise:
from random import shuffle
index = list(index)
shuffle(index)
sequential = False
if sequential:
for validation in array_split(index, K):
training = [i for i in index if i not in validation]
yield training, validation
else:
for k in xrange(K):
training = [i for i in index if i % K != k]
validation = [i for i in index if i % K == k]
yield training, validation
def shuffle_diag(shape, K, randomise=False, sequential=False):
"""
Generates k (training, validation) index pairs.
"""
m, n = shape
if K>m or K>n:
msg = "You may not use more subsets than max(n_rows, n_cols)"
raise ValueError, msg
mon = max(m, n)
#index = xrange(n)
index = [i for i in range(m*n) if i % m == 0]
print index
if randomise:
from random import shuffle
index = list(index)
shuffle(index)
sequential = False
if sequential:
start_inds = array_split(index, K)
else:
for k in xrange(K):
start_inds = [index[i] for i in xrange(n) if i % K == k]
print start_inds
for start in start_inds:
ind = arange(start, n*m, mon+1)
yield ind

View File

@ -1,438 +0,0 @@
import time
import cPickle
from scipy import zeros,zeros_like,sqrt,dot,trace,sign,round_,argmax,\
sort,ravel,newaxis,asarray,diag,sum,outer,argsort,arange,ones_like,\
all,apply_along_axis,eye,atleast_2d,empty
from scipy.linalg import svd,inv,norm,det,sqrtm
from numpy import median
#import plots_lpls
from cx_utils import mat_center
from validation import pls_jkW, lpls_jk
from select_generators import shuffle_1d
from engines import pca, pls, bridge
from engines import nipals_lpls as lpls
def hotelling(Pcv, P, p_center='med', cov_center='med',
alpha=0.3, crot=True, strict=False):
"""Returns regularized hotelling T^2.
alpha -- regularisation towards pooled cov estimates
beta -- regularisation for unstable eigenvalues
p_center -- location method for submodels
cov_center -- location method for sub coviariances
alpha -- regularisation
crot -- rotate submodels toward full?
strict -- only rotate 90 degree ?
"""
m, n = P.shape
n_sets, n, amax = Pcv.shape
# allocate
T_sq = empty((n, ),dtype='d')
Cov_i = zeros((n, amax, amax),dtype='d')
# rotate sub_models to full model
if crot:
for i, Pi in enumerate(Pcv):
Pcv[i] = procrustes(P, Pi, strict=strict)
# center of pnull
if p_center=='med':
P_ctr = median(Pcv, 0)
elif p_center=='mean':
# fixme: mean is unstable
P_ctr = Pcv.mean(0)
else: #use full
P_ctr = P
for i in xrange(n):
Pi = Pcv[:,i,:] # (n_sets x amax)
Pi_ctr = P_ctr[i,:] # (1 x amax)
Pim = (Pi - Pi_ctr[newaxis])*sqrt(n_sets-1)
Cov_i[i] = (1./n_sets)*dot(Pim.T, Pim)
if cov_center == 'med':
Cov = median(Cov_i, 0)
else:
Cov = Cov_i.mean(0)
reg_cov = (1. - alpha)*Cov_i + alpha*Cov
for i in xrange(n):
#Pc = P_ctr[i,:][:,newaxis]
Pc = P_ctr[i,:]
sigma = reg_cov[i]
# T_sq[i] = (dot(Pc, inv(sigma) )*Pc).sum() #slow
T_sq[i] = dot(dot(Pc, inv(sigma)), Pc) # dont need to care about transposes
#T_sq[i] = dot(dot(Pc.T, inv(sigma)), Pc).ravel()
return T_sq
def procrustes(A, B, strict=True, center=False, verbose=False):
"""Rotation of B to A.
strict -- Only do flipping and shuffling
center -- Center before rotation, translate back after
verbose -- Print ssq
No scaling calculated.
Output B_rot = Rotated B
"""
if center:
A,mn_A = mat_center(A, ret_mn=True)
B,mn_B = mat_center(B, ret_mn=True)
u,s,vh = svd(dot(B.T, A))
v = vh.T
Cm = dot(u, v.T) #orthogonal rotation matrix
if strict: # just inverting and flipping
Cm = ensure_strict(Cm)
b_rot = dot(B, Cm)
if verbose:
print Cm.round()
fit = sum(ravel(B - b_rot)**2)
print "Sum of squares: %s" %fit
if center:
return mn_B + b_rot
else:
return b_rot
def expl_var_x(Xc, T):
"""Returns explained variance of X.
T should carry variance in length, Xc has zero col-mean.
"""
exp_var_x = diag(dot(T.T, T))*100/(sum(Xc**2))
return exp_var_x
def expl_var_y(Y, T, Q):
"""Returns explained variance of Y.
"""
# centered Y
exp_var_y = zeros((Q.shape[1], ))
for a in range(Q.shape[1]):
Ya = outer(T[:,a], Q[:,a])
exp_var_y[a] = 100*sum(Ya**2)/sum(Y**2)
return exp_var_y
def pls_qvals(a, b, aopt=None, alpha=.3,
n_iter=20, algo='pls',
center=True,
sim_method='shuffle',
p_center='med', cov_center='med',
crot=True, strict=False):
"""Returns qvals for pls model.
input:
a -- data matrix
b -- data matrix
aopt -- scalar, opt. number of components
alpha -- [0,1] regularisation parameter for T2-test
n_iter -- number of permutations
sim_method -- permutation method ['shuffle']
p_center -- location estimator for sub models ['med']
cov_center -- location estimator for covariance of submodels ['med']
crot -- bool, use rotations of sub models?
strict -- bool, use stict (rot/flips only) rotations?
"""
m, n = a.shape
TSQ = zeros((n, n_iter), dtype='d') # (nvars x n_subsets)
n_false = zeros((n, n_iter), dtype='d')
#full model
if center:
ac = a - a.mean(0)
bc = b - b.mean(0)
if algo=='bridge':
dat = bridge(ac, bc, aopt, 'loads', 'fast')
else:
dat = pls(ac, bc, aopt, 'loads', 'fast')
Wcv = pls_jkW(a, b, aopt, n_blocks=None, algo=algo,center=True)
tsq_full = hotelling(Wcv, dat['W'], p_center=p_center,
alpha=alpha, crot=crot, strict=strict,
cov_center=cov_center)
#t0 = time.time()
Vs = shuffle_1d(bc, n_iter, axis=0)
for i, b_shuff in enumerate(Vs):
#t1 = time.time()
if algo=='bridge':
dat = bridge(ac, b_shuff, aopt, 'loads','fast')
else:
dat = pls(ac, b_shuff, aopt, 'loads', 'fast')
Wcv = pls_jkW(a, b_shuff, aopt, n_blocks=None, algo=algo)
TSQ[:,i] = hotelling(Wcv, dat['W'], p_center=p_center,
alpha=alpha, crot=crot, strict=strict,
cov_center=cov_center)
#print time.time() - t1
return fdr(tsq_full, TSQ, median)
def ensure_strict(C, only_flips=True):
"""Ensure that a rotation matrix does only 90 degree rotations.
In multiplication with pcs this allows flips and reordering.
if only_flips is True there will onlt be flips allowed
"""
Cm = C
S = sign(C) # signs
if only_flips==True:
C = eye(Cm.shape[0])*S
return C
Cm = zeros_like(C)
Cm.putmask(1.,abs(C)>.6)
if det(Cm)>1:
raise ValueError,"Implement this!"
return Cm*S
def pls_qvals_II(a, b, aopt=None, center=True, alpha=.3,
n_iter=20, algo='pls',
sim_method='shuffle',
p_center='med', cov_center='med',
crot=True, strict=False):
"""Returns qvals for pls model.
Shuffling of variables in X.
Null model is 'If I put genes randomly on network' ... if they are sign:
then this is due to network structure and not covariance with response.
input:
a -- data matrix
b -- data matrix
aopt -- scalar, opt. number of components
alpha -- [0,1] regularisation parameter for T2-test
n_iter -- number of permutations
sim_method -- permutation method ['shuffle']
p_center -- location estimator for sub models ['med']
cov_center -- location estimator for covariance of submodels ['med']
crot -- bool, use rotations of sub models?
strict -- bool, use stict (rot/flips only) rotations?
"""
m, n = a.shape
TSQ = zeros((n, n_iter), dtype='<f8') # (nvars x n_subsets)
n_false = zeros((n, n_iter), dtype='<f8')
#full model
# center?
if center==True:
ac = a - a.mean(0)
bc = b - b.mean(0)
if algo=='bridge':
dat = bridge(ac, bc, aopt, 'loads', 'fast')
else:
dat = pls(ac, bc, aopt, 'loads', 'fast')
Wcv = pls_jkW(a, b, aopt, n_blocks=None, algo=algo)
tsq_full = hotelling(Wcv, dat['W'], p_center=p_center,
alpha=alpha, crot=crot, strict=strict,
cov_center=cov_center)
t0 = time.time()
Vs = shuffle_1d(a, n_iter, 1)
for i, a_shuff in enumerate(Vs):
t1 = time.time()
a = a_shuff - a_shuff.mean(0)
if algo=='bridge':
dat = bridge(a, b, aopt, 'loads','fast')
else:
dat = pls(a, b, aopt, 'loads', 'fast')
Wcv = pls_jkW(a, b, aopt, n_blocks=None, algo=algo)
TSQ[:,i] = hotelling(Wcv, dat['W'], p_center=p_center,
alpha=alpha, crot=crot, strict=strict,
cov_center=cov_center)
print time.time() - t1
sort_index = argsort(tsq_full)[::-1]
back_sort_index = sort_index.argsort()
print time.time() - t0
# count false positives
tsq_full_sorted = tsq_full.take(sort_index)
for i in xrange(n_iter):
for j in xrange(n):
n_false[j,i] = sum(TSQ[:,i]>=tsq_full[j])
false_pos = median(n_false, 1)
ll = arange(1, len(false_pos)+1, 1)
sort_qval = false_pos.take(sort_index)/ll
qval = false_pos/ll.take(back_sort_index)
print time.time() - t0
#return qval, false_pos, TSQ, tsq_full
return qval
def leverage(aopt=1,*args):
"""Returns leverages
input : aopt, number of components to base leverage calculations on
*args, matrices of normed blm-paramters
output: leverages
For PCA typical inputs are normalised T or normalised P
For PLSR typical inputs are normalised T or normalised W
"""
if aopt<1:
raise ValueError,"Leverages only make sense for aopt>0"
lev = []
for u in args:
lev_u = 1./u.shape[0] + dot(u[:,:aopt], u[:,:aopt].T).diagonal()
lev.append(lev_u)
return lev
def variances(a, t, p):
"""Returns explained variance and ind. var from blm-params.
input:
a -- full centered matrix
t,p -- parameters from a bilinear approx of the above matrix.
output:
var -- variance of each component
var_exp -- cumulative explained variance in percentage
Typical inputs are: X(centered),T,P for PCA or
X(centered),T,P / Y(centered),T,Q for PLSR.
"""
tot_var = sum(a**2)
var = 100*(sum(p**2, 0)*sum(t**2, 0))/tot_var
var_exp = var.cumsum()
return var, var_exp
def residual_diagnostics(Y, Yhat, aopt=1):
"""Root mean errors and press values.
R2 vals
"""
pass
def ssq(E, axis=0, weights=None):
"""Sum of squares, supports weights."""
n = E.shape[axis]
if weights==None:
weights = eye(n)
else:
weigths = diag(weigths)
if axis==0:
Ew = dot(weights, E)
elif axis==1:
Ew = dot(E, weights)
else:
raise NotImplementedError, "Higher order modes not supported"
return pow(Ew,2).sum(axis)
def vnorm(x):
"""Returns the euclidian norm of a vector.
This is considerably faster than linalg.norm
"""
return sqrt(dot(x,x.conj()))
def mahalanobis(a, loc=None, acov=None, invcov=None):
"""Returns the distance of each observation in a
from the location estimate (loc) of the data,
relative to the shape of the data.
a : data matrix (n observations in rows, p variables in columns)
loc : location estimate of the data (p-dimensional vector)
covmat or invcov : scatter estimate of the data or the inverse of the scatter estimate (pxp matrix)
:Returns:
A vector containing the distances of all the observations to locvct.
"""
n, p = a.shape
if loc==None:
loc = a.mean(0)
loc = atleast_2d(loc)
if loc.shape[1]==1:
loc = loc.T; #ensure rowvector
assert(loc.shape[1]==p)
xc = a - loc
if acov==None and invcov==None:
acov = dot(xc.T, xc)
if invcov != None:
covmat = atleast_2d(invcov)
if min(covmat.shape)==1:
covmat = diag(invcov.ravel())
else:
covmat = atleast_2d(acov)
if min(covmat.shape)==1:
covmat = diag(covmat.ravel())
covmat = inv(covmat)
# mdist = diag(dot(dot(xc, covmat),xc.T))
mdist = (dot(xc, covmat)*xc).sum(1)
return mdist
def lpls_qvals(a, b, c, aopt=None, alpha=.3, zx_alpha=.5, n_iter=20,
sim_method='shuffle',p_center='med', cov_center='med',crot=True,
strict=False, mean_ctr=[2,0,2], nsets=None):
"""Returns qvals for l-pls model.
input:
a -- data matrix
b -- data matrix
c -- data matrix
aopt -- scalar, opt. number of components
alpha -- [0,1] regularisation parameter for T2-test
xz_alpha -- [0,1] how much z info to include
n_iter -- number of permutations
sim_method -- permutation method ['shuffle']
p_center -- location estimator for sub models ['med']
cov_center -- location estimator for covariance of submodels ['med']
crot -- bool, use rotations of sub models?
strict -- bool, use stict (rot/flips only) rotations?
"""
m, n = a.shape
p, k = c.shape
pert_tsq_x = zeros((n, n_iter), dtype='d') # (nxvars x n_subsets)
pert_tsq_z = zeros((p, n_iter), dtype='d') # (nzvars x n_subsets)
# Full model
#print "Full model start"
dat = lpls(a, b, c, aopt, scale='loads', mean_ctr=mean_ctr)
Wc, Lc = lpls_jk(a, b, c , aopt, nsets=nsets)
#print "Full hot"
cal_tsq_x = hotelling(Wc, dat['W'], alpha = alpha)
cal_tsq_z = hotelling(Lc, dat['L'], alpha = 0)
# Perturbations
Vs = shuffle_1d(b, n_iter, axis=0)
for i, b_shuff in enumerate(Vs):
print i
dat = lpls(a, b_shuff,c, aopt, scale='loads', mean_ctr=mean_ctr)
Wi, Li = lpls_jk(a, b_shuff, c, aopt, nsets=nsets)
pert_tsq_x[:,i] = hotelling(Wi, dat['W'], alpha=alpha)
pert_tsq_z[:,i] = hotelling(Li, dat['L'], alpha=alpha)
return cal_tsq_z, pert_tsq_z, cal_tsq_x, pert_tsq_x
def fdr(tsq, tsqp, loc_method='mean'):
n, = tsq.shape
k, m = tsqp.shape
assert(n==k)
n_false = empty((n, m), 'd')
sort_index = argsort(tsq)[::-1]
r_index = argsort(sort_index)
for i in xrange(m):
for j in xrange(n):
n_false[j,i] = (tsqp[:,i]>tsq[j]).sum()
#cPickle.dump(n_false, open("/tmp/nfalse.dat_"+str(n), "w"))
if loc_method=='mean':
fp = n_false.mean(1)
elif loc_method == 'median':
fp = median(n_false.T)
else:
raise ValueError
n_signif = (arange(n) + 1.0)[r_index]
fd_rate = fp/n_signif
return fd_rate

View File

@ -1,115 +0,0 @@
from scipy import apply_along_axis,newaxis,zeros,\
median,round_,nonzero,dot,argmax,any,sqrt,ndarray,\
trace,zeros_like,sign,sort,real,argsort,rand,array,\
matrix,nan
from scipy.linalg import norm,svd,inv,eig
from numpy import median
def normalise(a, axis=0, return_scales=False):
s = apply_along_axis(norm, axis, a)
if axis==0:
s = s[newaxis]
else:
s = s[:,newaxis]
a_s = a/s
if return_scales:
return a_s, s
return a_s
def sub2ind(shape, i, j):
"""Indices from subscripts. Only support for 2d"""
row,col = shape
ind = []
for k in xrange(len(i)):
for m in xrange(len(j)):
ind.append(i[k]*col + j[m])
return ind
def sorted_eig(a, b=None,sort_by='sm'):
"""
Just eig with real part of output sorted:
This is for convenience only, not general!
sort_by='sm': return the eigenvectors by eigenvalues
of smallest magnitude first. (default)
'lm': returns largest eigenvalues first
output: just as eig with 2 outputs
-- s,v (eigvals,eigenvectors)
(This is reversed output compared to matlab)
"""
s,v = eig(a, b)
s = real(s) # dont expect any imaginary part
v = real(v)
ind = argsort(s)
if sort_by=='lm':
ind = ind[::-1]
v = v.take(ind, 1)
s = s.take(ind)
return s,v
def str2num(string_number):
"""Convert input (string number) into number, if float(string_number) fails, a nan is inserted.
"""
missings = ['','nan','NaN','NA']
try:
num = float(string_number)
except:
if string_number in missings:
num = nan
else:
print "Found strange entry: %s" %string_number
raise
return num
def randperm(n):
r = rand(n)
dict={}
for i in range(n):
dict[r[i]] = i
r = sort(r)
out = zeros(n)
for i in range(n):
out[i] = dict[r[i]]
return array(out).astype('i')
def mat_center(X,axis=0,ret_mn=False):
"""Mean center matrix along axis.
X -- matrix, data
axis -- dim,
ret_mn -- bool, return mean
output:
Xc, [mnX]
NB: axis = 1 is column-centering, axis=0=row-centering
default is row centering (axis=0)
"""
try:
rows,cols = X.shape
except ValueError:
print "The X data needs to be two-dimensional"
if axis==0:
mnX = X.mean(axis)[newaxis]
Xs = X - mnX
elif axis==1:
mnX = X.mean(axis)[newaxis]
Xs = (X.T - mnX).T
if ret_mn:
return Xs,mnX
else:
return Xs
def m_shape(array):
"""Returns the array shape on the form of a numpy.matrix."""
return matrix(array).shape

View File

@ -1,879 +0,0 @@
"""Module contain algorithms for low-rank models.
There is almost no typechecking of any kind here, just focus on speed
"""
import math
import warnings
from scipy.linalg import svd,inv
from scipy import dot,empty,eye,newaxis,zeros,sqrt,diag,\
apply_along_axis,mean,ones,randn,empty_like,outer,r_,c_,\
rand,sum,cumsum,matrix, expand_dims,minimum,where,arange,inner,tile
has_sym = True
has_arpack = True
try:
from symeig import symeig
except:
has_sym = False
try:
from scipy.sandbox import arpack
except:
has_arpack = False
def pca(a, aopt,scale='scores',mode='normal',center_axis=0):
""" Principal Component Analysis.
Performs PCA on given matrix and returns results in a dictionary.
:Parameters:
a : array
Data measurement matrix, (samples x variables)
aopt : int
Number of components to use, aopt<=min(samples, variables)
:Returns:
results : dict
keys -- values, T -- scores, P -- loadings, E -- residuals,
lev --leverages, ssq -- sum of squares, expvar -- cumulative
explained variance, aopt -- number of components used
:OtherParam eters:
mode : str
Amount of info retained, ('fast', 'normal', 'detailed')
center_axis : int
Center along given axis. If neg.: no centering (-inf,..., matrix modes)
:SeeAlso:
- pcr : other blm
- pls : other blm
- lpls : other blm
Notes
-----
Uses kernel speed-up if m>>n or m<<n.
If residuals turn rank deficient, a lower number of component than given
in input will be used. The number of components used is given in
results-dict.
Examples
--------
>>> import scipy,engines
>>> a=scipy.asarray([[1,2,3],[2,4,5]])
>>> dat=engines.pca(a, 2)
>>> dat['expvarx']
array([0.,99.8561562, 100.])
"""
m, n = a.shape
assert(aopt<=min(m,n))
if center_axis>=0:
a = a - expand_dims(a.mean(center_axis), center_axis)
if m>(n+100) or n>(m+100):
u, s, v = esvd(a, amax=None) # fixme:amax option need to work with expl.var
else:
u, s, vt = svd(a, 0)
v = vt.T
e = s**2
tol = 1e-10
eff_rank = sum(s>s[0]*tol)
aopt = minimum(aopt, eff_rank)
T = u*s
s = s[:aopt]
T = T[:,:aopt]
P = v[:,:aopt]
if scale=='loads':
T = T/s
P = P*s
if mode == 'fast':
return {'T':T, 'P':P, 'aopt':aopt}
if mode=='detailed':
E = empty((aopt, m, n))
ssq = []
lev = []
for ai in range(aopt):
E[ai,:,:] = a - dot(T[:,:ai+1], P[:,:ai+1].T)
ssq.append([(E[ai,:,:]**2).mean(0), (E[ai,:,:]**2).mean(1)])
if scale=='loads':
lev.append([((s*T)**2).sum(1), (P**2).sum(1)])
else:
lev.append([(T**2).sum(1), ((s*P)**2).sum(1)])
else:
# residuals
E = a - dot(T, P.T)
#E = a
SEP = E**2
ssq = [SEP.sum(0), SEP.sum(1)]
# leverages
if scale=='loads':
lev = [(1./m)+(T**2).sum(1), (1./n)+((P/s)**2).sum(1)]
else:
lev = [(1./m)+((T/s)**2).sum(1), (1./n)+(P**2).sum(1)]
# variances
expvarx = r_[0, 100*e.cumsum()/e.sum()][:aopt+1]
return {'T':T, 'P':P, 'E':E, 'expvarx':expvarx, 'levx':lev, 'ssqx':ssq, 'aopt':aopt, 'eigvals': e[:aopt,newaxis]}
def pcr(a, b, aopt, scale='scores',mode='normal',center_axis=0):
""" Principal Component Regression.
Performs PCR on given matrix and returns results in a dictionary.
:Parameters:
a : array
Data measurement matrix, (samples x variables)
b : array
Data response matrix, (samples x responses)
aopt : int
Number of components to use, aopt<=min(samples, variables)
:Returns:
results : dict
keys -- values, T -- scores, P -- loadings, E -- residuals,
levx -- leverages, ssqx -- sum of squares, expvarx -- cumulative
explained variance, aopt -- number of components used
:OtherParameters:
mode : str
Amount of info retained, ('fast', 'normal', 'detailed')
center_axis : int
Center along given axis. If neg.: no centering (-inf,..., matrix modes)
:SeeAlso:
- pca : other blm
- pls : other blm
- lpls : other blm
Notes
-----
Uses kernel speed-up if m>>n or m<<n.
If residuals turn rank deficient, a lower number of component than given
in input will be used. The number of components used is given in results-dict.
Examples
--------
>>> import scipy,engines
>>> a=scipy.asarray([[1,2,3],[2,4,5]])
>>> b=scipy.asarray([[1,1],[2,3]])
>>> dat=engines.pcr(a, 2)
>>> dat['expvarx']
array([0.,99.8561562, 100.])
"""
k, l = m_shape(b)
if center_axis>=0:
b = b - expand_dims(b.mean(center_axis), center_axis)
dat = pca(a, aopt=aopt, scale=scale, mode=mode, center_axis=center_axis)
T = dat['T']
weights = apply_along_axis(vnorm, 0, T)**2
if scale=='loads':
Q = dot(b.T, T*weights)
else:
Q = dot(b.T, T/weights)
if mode=='fast':
dat.update({'Q':Q})
return dat
if mode=='detailed':
F = empty((aopt, k, l))
for i in range(aopt):
F[i,:,:] = b - dot(T[:,:i+1], Q[:,:i+1].T)
else:
F = b - dot(T, Q.T)
expvary = r_[0, 100*((T**2).sum(0)*(Q**2).sum(0)/(b**2).sum()).cumsum()[:aopt]]
#fixme: Y-var leverages
dat.update({'Q':Q, 'F':F, 'expvary':expvary})
return dat
def pls(a, b, aopt=2, scale='scores', mode='normal', center_axis=-1, ab=None):
"""Partial Least Squares Regression.
Performs PLS on given matrix and returns results in a dictionary.
:Parameters:
a : array
Data measurement matrix, (samples x variables)
b : array
Data response matrix, (samples x responses)
aopt : int
Number of components to use, aopt<=min(samples, variables)
:Returns:
results : dict
keys -- values, T -- scores, P -- loadings, E -- residuals,
levx -- leverages, ssqx -- sum of squares, expvarx -- cumulative
explained variance of descriptors, expvary -- cumulative explained
variance of responses, aopt -- number of components used
:OtherParameters:
mode : str
Amount of info retained, ('fast', 'normal', 'detailed')
center_axis : int
Center along given axis. If neg.: no centering (-inf,..., matrix modes)
:SeeAlso:
- pca : other blm
- pcr : other blm
- lpls : other blm
Notes
-----
Uses kernel speed-up if m>>n or m<<n.
If residuals turn rank deficient, a lower number of component than given
in input will be used. The number of components used is given in results-dict.
Examples
--------
>>> import scipy,engines
>>> a=scipy.asarray([[1,2,3],[2,4,5]])
>>> b=scipy.asarray([[1,1],[2,3]])
>>> dat=engines.pls(a, b, 2)
>>> dat['expvarx']
array([0.,99.8561562, 100.])
"""
m, n = m_shape(a)
if ab!=None:
mm, l = m_shape(ab)
assert(m==mm)
else:
k, l = m_shape(b)
if center_axis>=0:
a = a - expand_dims(a.mean(center_axis), center_axis)
b = b - expand_dims(b.mean(center_axis), center_axis)
W = empty((n, aopt))
P = empty((n, aopt))
R = empty((n, aopt))
Q = empty((l, aopt))
T = empty((m, aopt))
B = empty((aopt, n, l))
tt = empty((aopt,))
if ab==None:
ab = dot(a.T, b)
for i in range(aopt):
if ab.shape[1]==1: #pls 1
w = ab.reshape(n, l)
w = w/vnorm(w)
elif n<l: # more yvars than xvars
if has_sym:
s, w = symeig(dot(ab, ab.T),range=[n,n],overwrite=True)
else:
w, s, vh = svd(dot(ab, ab.T))
w = w[:,:1]
else: # standard wide xdata
if has_sym:
s, q = symeig(dot(ab.T, ab),range=[l,l],overwrite=True)
else:
q, s, vh = svd(dot(ab.T, ab))
q = q[:,:1]
w = dot(ab, q)
w = w/vnorm(w)
r = w.copy()
if i>0:
for j in range(0, i, 1):
r = r - dot(P[:,j].T, w)*R[:,j][:,newaxis]
t = dot(a, r)
tt[i] = tti = dot(t.T, t).ravel()
p = dot(a.T, t)/tti
q = dot(r.T, ab).T/tti
ab = ab - dot(p, q.T)*tti
T[:,i] = t.ravel()
W[:,i] = w.ravel()
if mode=='fast' and i==aopt-1:
if scale=='loads':
tnorm = sqrt(tt)
T = T/tnorm
W = W*tnorm
return {'T':T, 'W':W}
P[:,i] = p.ravel()
R[:,i] = r.ravel()
Q[:,i] = q.ravel()
#B[i] = dot(R[:,:i+1], Q[:,:i+1].T)
qnorm = apply_along_axis(vnorm, 0, Q)
tnorm = sqrt(tt)
pp = (P**2).sum(0)
if mode=='detailed':
E = empty((aopt, m, n))
F = empty((aopt, k, l))
ssqx, ssqy = [], []
leverage = empty((aopt, m))
h2x = [] #hotellings T^2
h2y = []
for ai in range(aopt):
E[ai,:,:] = a - dot(T[:,:ai+1], P[:,:ai+1].T)
F[i-1] = b - dot(T[:,:i], Q[:,:i].T)
ssqx.append([(E[ai,:,:]**2).mean(0), (E[ai,:,:]**2).mean(1)])
ssqy.append([(F[ai,:,:]**2).mean(0), (F[ai,:,:]**2).mean(1)])
leverage[ai,:] = 1./m + ((T[:,:ai+1]/tnorm[:ai+1])**2).sum(1)
h2y.append(1./k + ((Q[:,:ai+1]/qnorm[:ai+1])**2).sum(1))
else:
# residuals
E = a - dot(T, P.T)
F = b - dot(T, Q.T)
sepx = E**2
ssqx = [sepx.sum(0), sepx.sum(1)]
sepy = F**2
ssqy = [sepy.sum(0), sepy.sum(1)]
# leverage
leverage = 1./m + ((T/tnorm)**2).sum(1)
h2x = []
h2y = []
# variances
tp= tt*pp
tq = tt*qnorm*qnorm
expvarx = r_[0, 100*tp/(a*a).sum()]
expvary = r_[0, 100*tq/(b*b).sum()]
if scale=='loads':
T = T/tnorm
W = W*tnorm
Q = Q*tnorm
P = P*tnorm
return {'Q':Q, 'P':P, 'T':T, 'W':W, 'R':R, 'E':E, 'F':F,
'expvarx':expvarx, 'expvary':expvary, 'ssqx':ssqx, 'ssqy':ssqy,
'leverage':leverage, 'h2':h2x}
def w_simpls(aat, b, aopt):
""" Simpls for wide matrices.
Fast pls for crossval, used in calc rmsep for wide X
There is no P or W. T is normalised
"""
bb = b.copy()
m, m = aat.shape
U = empty((m, aopt)) # W
T = empty((m, aopt))
H = empty((m, aopt)) # R
PROJ = empty((m, aopt)) # P?
for i in range(aopt):
q, s, vh = svd(dot(dot(b.T, aat), b), full_matrices=0)
u = dot(b, q[:,:1]) #y-factor scores
U[:,i] = u.ravel()
t = dot(aat, u)
t = t/vnorm(t)
T[:,i] = t.ravel()
h = dot(aat, t) #score-weights
H[:,i] = h.ravel()
PROJ[:,:i+1] = dot(T[:,:i+1], inv(dot(T[:,:i+1].T, H[:,:i+1])) )
if i<aopt:
b = b - dot(PROJ[:,:i+1], dot(H[:,:i+1].T,b) )
C = dot(bb.T, T)
return {'T':T, 'U':U, 'Q':C, 'H':H}
def w_pls(aat, b, aopt):
""" Pls for wide matrices.
Fast pls for crossval, used in calc rmsep for wide X
There is no P or W. T is normalised
aat = centered kernel matrix
b = centered y
"""
bb = b.copy()
k, l = m_shape(b)
m, m = m_shape(aat)
U = empty((m, aopt)) # W
T = empty((m, aopt))
R = empty((m, aopt)) # R
PROJ = empty((m, aopt)) # P?
for i in range(aopt):
if has_sym:
s, q = symeig(dot(dot(b.T, aat), b), range=(l,l),overwrite=True)
else:
q, s, vh = svd(dot(dot(b.T, aat), b), full_matrices=0)
q = q[:,:1]
u = dot(b , q) #y-factor scores
U[:,i] = u.ravel()
t = dot(aat, u)
t = t/vnorm(t)
T[:,i] = t.ravel()
r = dot(aat, t)#score-weights
#r = r/vnorm(r)
R[:,i] = r.ravel()
PROJ[:,: i+1] = dot(T[:,:i+1], inv(dot(T[:,:i+1].T, R[:,:i+1])) )
if i<aopt:
b = b - dot(PROJ[:,:i+1], dot(R[:,:i+1].T, b) )
C = dot(bb.T, T)
return {'T':T, 'U':U, 'Q':C, 'R':R}
def bridge(a, b, aopt, scale='scores', mode='normal', r=0):
"""Undeflated Ridged svd(X'Y)
"""
m, n = m_shape(a)
k, l = m_shape(b)
u, s, vt = svd(b, full_matrices=0)
g0 = dot(u*s, u.T)
g = (1 - r)*g0 + r*eye(m)
ag = dot(a.T, g)
u, s, vt = svd(ag, full_matrices=0)
W = u[:,:aopt]
K = vt[:aopt,:].T
T = dot(a, W)
tnorm = apply_along_axis(vnorm, 0, T) # norm of T-columns
if mode == 'fast':
if scale=='loads':
T = T/tnorm
W = W*tnorm
return {'T':T, 'W':W}
U = dot(g0, K) #fixme check this
Q = dot(b.T, dot(T, inv(dot(T.T, T)) ))
B = zeros((aopt, n, l), dtype='f')
for i in range(aopt):
B[i] = dot(W[:,:i+1], Q[:,:i+1].T)
if mode == 'detailed':
E = empty((aopt, m, n))
F = empty((aopt, k, l))
for i in range(aopt):
E[i] = a - dot(T[:,:i+1], W[:,:i+1].T)
F[i] = b - dot(a, B[i])
else: #normal
F = b - dot(a, B[-1])
E = a - dot(T, W.T)
if scale=='loads':
T = T/tnorm
W = W*tnorm
Q = Q*tnorm
return {'B':B, 'W':W, 'T':T, 'Q':Q, 'E':E, 'F':F, 'U':U, 'P':W}
def nipals_lpls(X, Y, Z, a_max, alpha=.7, mean_ctr=[2, 0, 1], scale='scores', verbose=False):
""" L-shaped Partial Least Sqaures Regression by the nipals algorithm.
(X!Z)->Y
:input:
X : data matrix (m, n)
Y : data matrix (m, l)
Z : data matrix (n, o)
:output:
T : X-scores
W : X-weights/Z-weights
P : X-loadings
Q : Y-loadings
U : X-Y relation
L : Z-scores
K : Z-loads
B : Regression coefficients X->Y
b0: Regression coefficient intercept
evx : X-explained variance
evy : Y-explained variance
evz : Z-explained variance
mnx : X location
mny : Y location
mnz : Z location
:Notes:
"""
if mean_ctr!=None:
xctr, yctr, zctr = mean_ctr
X, mnX = center(X, xctr)
Y, mnY = center(Y, yctr)
Z, mnZ = center(Z, zctr)
varX = (X**2).sum()
varY = (Y**2).sum()
varZ = (Z**2).sum()
m, n = X.shape
k, l = Y.shape
u, o = Z.shape
# initialize
U = empty((k, a_max))
Q = empty((l, a_max))
T = empty((m, a_max))
W = empty((n, a_max))
P = empty((n, a_max))
K = empty((o, a_max))
L = empty((u, a_max))
B = empty((a_max, n, l))
#b0 = empty((a_max, 1, l))
var_x = empty((a_max,))
var_y = empty((a_max,))
var_z = empty((a_max,))
MAX_ITER = 250
LIM = 1e-1
for a in range(a_max):
if verbose:
print "\nWorking on comp. %s" %a
u = Y[:,:1]
diff = 1
niter = 0
while (diff>LIM and niter<MAX_ITER):
niter += 1
u1 = u.copy()
w = dot(X.T, u)
w = w/sqrt(dot(w.T, w))
#w = w/dot(w.T, w)
l = dot(Z, w)
k = dot(Z.T, l)
k = k/sqrt(dot(k.T, k))
#k = k/dot(k.T, k)
w = alpha*k + (1-alpha)*w
#print sqrt(dot(w.T, w))
w = w/sqrt(dot(w.T, w))
t = dot(X, w)
c = dot(Y.T, t)
c = c/sqrt(dot(c.T, c))
u = dot(Y, c)
diff = dot((u-u1).T, (u-u1))
if verbose:
print "Converged after %s iterations" %niter
print "Error: %.2E" %diff
tt = dot(t.T, t)
p = dot(X.T, t)/tt
q = dot(Y.T, t)/tt
l = dot(Z, w)
U[:,a] = u.ravel()
W[:,a] = w.ravel()
P[:,a] = p.ravel()
T[:,a] = t.ravel()
Q[:,a] = q.ravel()
L[:,a] = l.ravel()
K[:,a] = k.ravel()
X = X - dot(t, p.T)
Y = Y - dot(t, q.T)
Z = (Z.T - dot(w, l.T)).T
var_x[a] = pow(X, 2).sum()
var_y[a] = pow(Y, 2).sum()
var_z[a] = pow(Z, 2).sum()
B[a] = dot(dot(W[:,:a+1], inv(dot(P[:,:a+1].T, W[:,:a+1]))), Q[:,:a+1].T)
#b0[a] = mnY - dot(mnX, B[a])
# variance explained
evx = 100.0*(1 - var_x/varX)
evy = 100.0*(1 - var_y/varY)
evz = 100.0*(1 - var_z/varZ)
if scale=='loads':
tnorm = apply_along_axis(vnorm, 0, T)
T = T/tnorm
W = W*tnorm
Q = Q*tnorm
knorm = apply_along_axis(vnorm, 0, K)
L = L*knorm
K = K/knorm
return {'T':T, 'W':W, 'P':P, 'Q':Q, 'U':U, 'L':L, 'K':K, 'B':B, 'evx':evx, 'evy':evy, 'evz':evz,'mnx': mnX, 'mny': mnY, 'mnz': mnZ}
def nipals_pls(X, Y, a_max, alpha=.7, ax_center=0, mode='normal', scale='scores', verbose=False):
"""Partial Least Sqaures Regression by the nipals algorithm.
(X!Z)->Y
:input:
X : data matrix (m, n)
Y : data matrix (m, l)
:output:
T : X-scores
W : X-weights/Z-weights
P : X-loadings
Q : Y-loadings
U : X-Y relation
B : Regression coefficients X->Y
b0: Regression coefficient intercept
evx : X-explained variance
evy : Y-explained variance
evz : Z-explained variance
:Notes:
"""
if ax_center>=0:
mn_x = expand_dims(X.mean(ax_center), ax_center)
mn_y = expand_dims(Y.mean(ax_center), ax_center)
X = X - mn_x
Y = Y - mn_y
varX = pow(X, 2).sum()
varY = pow(Y, 2).sum()
m, n = X.shape
k, l = Y.shape
# initialize
U = empty((k, a_max))
Q = empty((l, a_max))
T = empty((m, a_max))
W = empty((n, a_max))
P = empty((n, a_max))
B = empty((a_max, n, l))
b0 = empty((a_max, m, l))
var_x = empty((a_max,))
var_y = empty((a_max,))
t1 = X[:,:1]
for a in range(a_max):
if verbose:
print "\n Working on comp. %s" %a
u = Y[:,:1]
diff = 1
MAX_ITER = 100
lim = 1e-16
niter = 0
while (diff>lim and niter<MAX_ITER):
niter += 1
#u1 = u.copy()
w = dot(X.T, u)
w = w/sqrt(dot(w.T, w))
#l = dot(Z, w)
#k = dot(Z.T, l)
#k = k/sqrt(dot(k.T, k))
#w = alpha*k + (1-alpha)*w
#w = w/sqrt(dot(w.T, w))
t = dot(X, w)
q = dot(Y.T, t)
q = q/sqrt(dot(q.T, q))
u = dot(Y, q)
diff = vnorm(t1 - t)
t1 = t.copy()
if verbose:
print "Converged after %s iterations" %niter
#tt = dot(t.T, t)
#p = dot(X.T, t)/tt
#q = dot(Y.T, t)/tt
#l = dot(Z, w)
p = dot(X.T, t)/dot(t.T, t)
p_norm = vnorm(p)
t = t*p_norm
w = w*p_norm
p = p/p_norm
U[:,a] = u.ravel()
W[:,a] = w.ravel()
P[:,a] = p.ravel()
T[:,a] = t.ravel()
Q[:,a] = q.ravel()
X = X - dot(t, p.T)
Y = Y - dot(t, q.T)
var_x[a] = pow(X, 2).sum()
var_y[a] = pow(Y, 2).sum()
B[a] = dot(dot(W[:,:a+1], inv(dot(P[:,:a+1].T, W[:,:a+1]))), Q[:,:a+1].T)
b0[a] = mn_y - dot(mn_x, B[a])
# variance explained
evx = 100.0*(1 - var_x/varX)
evy = 100.0*(1 - var_y/varY)
if scale=='loads':
tnorm = apply_along_axis(vnorm, 0, T)
T = T/tnorm
W = W*tnorm
Q = Q*tnorm
return {'T':T, 'W':W, 'P':P, 'Q':Q, 'U':U, 'B':B, 'b0':b0, 'evx':evx, 'evy':evy,
'mnx': mnX, 'mny': mnY, 'xc': X, 'yc': Y}
########### Helper routines #########
def m_shape(array):
return matrix(array).shape
def esvd(data, amax=None):
"""SVD with the option of economy sized calculation
Calculate subspaces of X'X or XX' depending on the shape
of the matrix.
Good for extreme fat or thin matrices
:notes:
Numpy supports this by setting full_matrices=0
"""
has_arpack = True
try:
import arpack
except:
has_arpack = False
m, n = data.shape
if m>=n:
kernel = dot(data.T, data)
if has_arpack:
if amax==None:
amax = n
s, v = arpack.eigen_symmetric(kernel,k=amax, which='LM',
maxiter=200,tol=1e-5)
if has_sym:
if amax==None:
amax = n
pcrange = None
else:
pcrange = [n-amax, n]
s, v = symeig(kernel, range=pcrange, overwrite=True)
s = s[::-1].real
v = v[:,::-1].real
else:
u, s, vt = svd(kernel)
v = vt.T
s = sqrt(s)
u = dot(data, v)/s
else:
kernel = dot(data, data.T)
if has_sym:
if amax==None:
amax = m
pcrange = None
else:
pcrange = [m-amax, m]
s, u = symeig(kernel, range=pcrange, overwrite=True)
s = s[::-1]
u = u[:,::-1]
else:
u, s, vt = svd(kernel)
s = sqrt(s)
v = dot(data.T, u)/s
# some use of symeig returns the 0 imaginary part
return u.real, s.real, v.real
def vnorm(x):
# assume column arrays (or vectors)
return math.sqrt(dot(x.T, x))
def center(a, axis):
# 0 = col center, 1 = row center, 2 = double center
# -1 = nothing
# check if we have a vector
is_vec = len(a.shape)==1
if not is_vec:
is_vec = a.shape[0]==1 or a.shape[1]==1
if is_vec:
if axis==2:
warnings.warn("Double centering of vecor ignored, using ordinary centering")
if axis==-1:
mn = 0
else:
mn = a.mean()
return a - mn, mn
# !!!fixme: use broadcasting
if axis==-1:
mn = zeros((1,a.shape[1],))
#mn = tile(mn, (a.shape[0], 1))
elif axis==0:
mn = a.mean(0)[newaxis]
#mn = tile(mn, (a.shape[0], 1))
elif axis==1:
mn = a.mean(1)[:,newaxis]
#mn = tile(mn, (1, a.shape[1]))
elif axis==2:
mn = a.mean(0)[newaxis] + a.mean(1)[:,newaxis] - a.mean()
return a - mn , a.mean(0)[newaxis]
else:
raise IOError("input error: axis must be in [-1,0,1,2]")
return a - mn, mn
def scale(a, axis):
if axis==-1:
sc = zeros((a.shape[1],))
elif axis==0:
sc = a.std(0)
elif axis==1:
sc = a.std(1)[:,newaxis]
else:
raise IOError("input error: axis must be in [-1,0,1]")
return a - sc, sc
## #PCA CALCS
## % Calculate Q limit using unused eigenvalues
## temp = diag(s);
## if n < m
## emod = temp(lv+1:n,:);
## else
## emod = temp(lv+1:m,:);
## end
## th1 = sum(emod);
## th2 = sum(emod.^2);
## th3 = sum(emod.^3);
## h0 = 1 - ((2*th1*th3)/(3*th2^2));
## if h0 <= 0.0
## h0 = .0001;
## disp(' ')
## disp('Warning: Distribution of unused eigenvalues indicates that')
## disp(' you should probably retain more PCs in the model.')
## end
## q = th1*(((1.65*sqrt(2*th2*h0^2)/th1) + 1 + th2*h0*(h0-1)/th1^2)^(1/h0));
## disp(' ')
## disp('The 95% Q limit is')
## disp(q)
## if plots >= 1
## lim = [q q];
## plot(scl,res,scllim,lim,'--b')
## str = sprintf('Process Residual Q with 95 Percent Limit Based on %g PC Model',lv);
## title(str)
## xlabel('Sample Number')
## ylabel('Residual')
## pause
## end
## % Calculate T^2 limit using ftest routine
## if lv > 1
## if m > 300
## tsq = (lv*(m-1)/(m-lv))*ftest(.95,300,lv,2);
## else
## tsq = (lv*(m-1)/(m-lv))*ftest(.95,m-lv,lv,2);
## end
## disp(' ')
## disp('The 95% T^2 limit is')
## disp(tsq)
## % Calculate the value of T^2 by normalizing the scores to
## % unit variance and summing them up
## if plots >= 1.0
## temp2 = scores*inv(diag(ssq(1:lv,2).^.5));
## tsqvals = sum((temp2.^2)');
## tlim = [tsq tsq];
## plot(scl,tsqvals,scllim,tlim,'--b')
## str = sprintf('Value of T^2 with 95 Percent Limit Based on %g PC Model',lv);
## title(str)
## xlabel('Sample Number')
## ylabel('Value of T^2')
## end
## else
## disp('T^2 not calculated when number of latent variables = 1')
## tsq = 1.96^2;
## end

View File

@ -1,95 +0,0 @@
import scipy
try:
# FIXME: remove rpy in a more proper way
import rpy_does_not_exist
has_rpy = True
silent_eval = rpy.with_mode(rpy.NO_CONVERSION, rpy.r)
except:
has_rpy = False
def gene_hypergeo_test(selection, category_dataset):
"""Returns the pvals from a hypergeometric test of significance.
input:
-- selection: list of selected identifiers along 0 dim of cat.set
-- category dataset, categories along dim 1 (cols)
"""
gene_dim_name = category_dataset.get_dim_name(0)
category_dim_name = category_dataset.get_dim_name(1)
#categories
all_cats = category_dataset.get_identifiers(category_dim_name, sorted=True)
# gene_ids universe
all_genes = category_dataset.get_identifiers(gene_dim_name)
# signifcant genes
good_genes_all = list(selection)
gg_index = category_dataset.get_indices(gene_dim_name, good_genes_all)
# significant genes pr. category
good_genes_cat = []
for col in category_dataset.asarray().T:
index = scipy.where(col==1)[0]
index = scipy.intersect1d(index, gg_index)
if index.size==0:
good_genes_cat.append([])
else:
good_genes_cat.append(category_dataset.get_identifiers(gene_dim_name, index))
count = map(len, good_genes_cat)
count = scipy.asarray([max(i, 0) for i in count])
cat_count = category_dataset.asarray().sum(0)
if has_rpy:
rpy.r.assign("x", count - 1) #number of sign. genes in category i
rpy.r.assign("m", len(good_genes_all)) # number of sign. genes tot
rpy.r.assign("n", len(all_genes)-len(good_genes_all) ) # num. genes not sign.
rpy.r.assign("k", cat_count) #num. genes in cat i
silent_eval('pvals <- phyper(x, m, n, k, lower.tail=FALSE)')
pvals = rpy.r("pvals")
else:
pvals = p_hyper_geom(count, len(good_genes_all),
len(all_genes)-len(good_genes_all),
cat_count)
pvals = scipy.where(cat_count==0, 2, pvals)
pvals = scipy.where(scipy.isnan(pvals), 2, pvals)
out = {}
for i in range(pvals.size):
out[str(all_cats[i])] = (count[i], cat_count[i], pvals[i])
return out
def p_hyper_geom(x, m, n, k):
"""Distribution function for the hypergeometric distribution.
Inputs:
-- x: vector of quantiles representing the number of white balls
drawn without replacement from an urn which contains both
black and white balls.
-- m: the number of white balls in the urn.
-- n: the number of black balls in the urn.
-- k: [vector] the number of balls drawn from the urn
Comments:
Similar to R's phyper with lower.tail=FALSE
"""
M = m + n
multiple_draws = False
if isinstance(k, scipy.ndarray) and k.size>1:
multiple_draws = True
n_draws = k.size
if n_draws<x.size:
print "n_draws: %d and n_found: %d Length mismatch, zero padded" %(k.size, x.size)
N = k
n = m
if not multiple_draws:
out = scipy.stats.hypergeom.pmf(x, M, n, N).cumsum()
else:
out = scipy.zeros((max(n_draws, x.size),))
for i in xrange(N.size):
out[i] = scipy.stats.hypergeom.pmf(x, M, n, N[i]).cumsum()[i]
return out

View File

@ -1,567 +0,0 @@
import os,sys
from itertools import izip
import networkx as NX
from scipy import shape,diag,dot,asarray,sqrt,real,zeros,eye,exp,maximum,\
outer,maximum,sum,diag,real,atleast_2d
from scipy.linalg import eig,svd,inv,expm,norm
from cx_utils import sorted_eig
import numpy
eps = numpy.finfo(float).eps.item()
feps = numpy.finfo(numpy.single).eps.item()
_array_precision = {'f': 0, 'd': 1, 'F': 0, 'D': 1,'i': 1}
class NXUTILSException(Exception): pass
def xgraph_to_graph(G):
"""Convert an Xgraph to an ordinary graph.
Edge attributes, mult.edges and self-loops are lost in the process.
"""
GG = NX.convert.from_dict_of_lists(NX.convert.to_dict_of_lists(G))
return GG
def get_affinity_matrix(G, data, ids, dist='e', mask=None, weight=None, t=0, out='dist'):
"""
Function for calculating a general affinity matrix, based upon distances.
Affiniy = 1 - distance ((10-1) 1 is far apart)
INPUT
data:
gene expression data, type dict data[gene] = expression-vector
G:
The network (networkx.base.Graph object)
mask:
The array mask shows which data are missing. If mask[i][j]==0, then
data[i][j] is missing.
weights:
The array weight contains the weights to be used when calculating distances.
transpose:
If transpose==0, then genes are clustered. If transpose==1, microarrays are
clustered.
dist:
The character dist defines the distance function to be used:
dist=='e': Euclidean distance
dist=='b': City Block distance
dist=='h': Harmonically summed Euclidean distance
dist=='c': Pearson correlation
dist=='a': absolute value of the correlation
dist=='u': uncentered correlation
dist=='x': absolute uncentered correlation
dist=='s': Spearman's rank correlation
dist=='k': Kendall's tau
For other values of dist, the default (Euclidean distance) is used.
OUTPUT
D :
Similariy matrix (nGenes x nGenes), symetric, d_ij e in [0,1]
Normalized so max weight = 1.0
"""
try:
from Bio import Cluster as CLS
except:
raise NXUTILSError("Import of Biopython failed")
n_var = len(data)
n_samp = len(data[data.keys()[0]])
X = zeros((nVar, nSamp),dtpye='<f8')
for i, gene in enumerate(ids): #this shuld be right!!
X[i,:] = data[gene]
#X = transpose(X) # distancematrix needs matrix as (nGenes,nSamples)
D_list = CLS.distancematrix(X, dist=dist)
D = zeros((nVar,nVar),dtype='<f8')
for i,row in enumerate(D_list):
if i>0:
D[i,:len(row)]=row
D = D + D.T
MAX = 30.0
D_max = max(ravel(D))/MAX
D_n = D/D_max #normalised (max = 10.0)
D_n = (MAX+1.) - D_n #using correlation (inverse distance for dists)
A = NX.adj_matrix(G, nodelist=ids)
if out=='dist':
return D_n*A
elif out=='heat_kernel':
t=1.0
K = exp(-t*D*A)
return K
elif out=='complete':
return D_n
else:
return []
def remove_one_degree_nodes(G, iter=True):
"""Removes all nodes with only one neighbour. These nodes does
not contribute to community structure.
input:
G -- graph
iter -- True/False iteratively remove?
"""
G_copy = G.copy()
if iter==True:
while 1:
bad_nodes=[]
for node in G_copy.nodes():
if len(G_copy.neighbors(node))==1:
bad_nodes.append(node)
if len(bad_nodes)>0:
G_copy.delete_nodes_from(bad_nodes)
else:
break
else:
bad_nodes=[]
for ngb in G_copy.neighbors_iter():
if len(G_copy.neighbors(node))==1:
bad_nodes.append(node)
if len(bad_nodes)>0:
G_copy.delete_nodes_from(bad_nodes)
print "Deleted %s nodes from network" %(len(G)-len(G_copy))
return G_copy
def key_players(G, n=1, with_labels=False):
"""
Resilince measure
Identification of key nodes by fraction of nodes in
disconnected subgraph when the node is removed.
output:
fraction of nodes disconnected when node i is removed
"""
i=0
frac=[]
labels = {}
for node in G.nodes():
i+=1
print i
T = G.copy()
T.delete_node(node)
n_nodes = T.number_of_nodes()
sub_graphs = NX.connected_component_subgraphs(T)
n = len(sub_graphs)
if n>1:
strong_comp = sub_graphs[0]
fraction = 1.0 - 1.0*strong_comp.number_of_nodes()/n_nodes
frac.append(fraction)
labels[node]=fraction
else:
frac.append(0.0)
labels[node]=0.0
out = 1.0 - array(frac)
if with_labels==True:
return out,labels
else:
return out
def node_weighted_adj_matrix(G, weights=None, ave_type='harmonic', with_labels=False):
"""Return a weighted adjacency matrix of graph. The weights are
node weights.
input: G -- graph
weights -- dict, keys: nodes, values: weights
with_labels -- True/False, return labels?
output: A -- weighted eadjacency matrix
[index] -- node labels
"""
n=G.order()
# make an dictionary that maps vertex name to position
index={}
count=0
for node in G.nodes():
index[node]=count
count = count+1
a = zeros((n,n))
if type(G)=='networkx.xbase.XGraph':
raise
for head,tail in G.edges():
if ave_type == 'geometric':
a[index[head],index[tail]]= sqrt(weights[head]*weights[tail])
a[index[tail],index[head]]= a[index[head],index[tail]]
elif ave_type == 'harmonic':
a[index[head],index[tail]] = mean(weights[head],weights[tail])
a[index[tail],index[head]]= mean(weights[head],weights[tail])
if with_labels:
return a,index
else:
return a
def weighted_adj_matrix(G, with_labels=False):
"""Adjacency matrix of an XGraph whos weights are given in edges.
"""
A, labels = NX.adj_matrix(G, with_labels=True)
W = A.astype('<f8')
for orf, i in labels.items():
for orf2, j in labels.items():
if G.has_edge(orf, orf2):
edge_weight = G.get_edge(orf, orf2)
W[i,j] = edge_weight
W[j,i] = edge_weight
if with_labels==True:
return W, labels
else:
return W
def assortative_index(G):
"""Ouputs two vectors: the degree and the neighbor average degree.
Used to measure the assortative mixing. If the average degree is
pos. correlated with the degree we know that hubs tend to connect
to other hubs.
input: G, graph connected!!
ouput: d,mn_d: degree, and average degree of neighb.
(degree sorting from degree(with_labels=True))
"""
d = G.degree(with_labels=True)
out=[]
for node in G.nodes():
nn = G.neighbors(node)
if len(nn)>0:
nn_d = mean([float(d[i]) for i in nn])
out.append((d[node], nn_d))
return array(out).T
def struct_equivalence(G,n1,n2):
"""Returns the structural equivalence of a node pair. Two nodes
are structural equal if they share the same neighbors.
x_s = [ne(n1) union ne(n2) - ne(n1) intersection ne(n2)]/[ne(n1)
union ne(n2) + ne(n1) intersection ne(n2)]
ref: Brun et.al 2003
"""
#[ne(n1) union ne(n2) - ne(n1) intersection ne(n2
s1 = set(G.neighbors(n1))
s2 = set(G.neighbors(n2))
num_union = len(s1.union(s2))
num_intersection = len(s1.intersection(s2))
if num_union & num_intersection:
xs=0
else:
xs = (num_union - num_intersection)/(num_union + num_intersection)
return xs
def struct_equivalence_all(G):
"""Not finnished.
"""
A,labels = NX.adj_matrix(G,with_labels=True)
pass
def hamming_distance(n1,n2):
"""Not finnsihed.
"""
pass
def graph_corrcoeff(G, vec=None, nodelist=None, sim='corr'):
"""Returns the correlation coefficient for each node. The
correlation coefficient is between the node and its neighbours.
"""
if nodelist==None:
nodelist=G.nodes()
if vec == None:
vec = G.degree(nodelist)
if len(vec)!=len(nodelist):
raise NXUTILSError("The node value vector is not of same length (%s) as the nodelist(%s)") %(len(vec), len(nodelist))
A = NX.ad_matrix(G, nodelist=nodelist)
for i, node in enumerate(nodelist):
nei_i = A[i,:]==1
vec_i = vec[nei_i]
def weighted_laplacian(G,with_labels=False):
"""Return standard Laplacian of graph from a weighted adjacency matrix."""
n= G.order()
I = scipy.eye(n)
A = weighted_adj_matrix(G)
D = I*scipy.sum(A, 0)
L = D-A
if with_labels:
A,index = weighted_adj_matrix(G, with_labels=True)
return L, index
else:
return L
def grow_subnetworks(G, T2):
"""Return the highest scoring (T2-test) subgraph og G.
Use simulated annealing to identify highly grow subgraphs.
ref: -- Ideker et.al (Bioinformatics 18, 2002)
-- Patil and Nielsen (PNAS 2006)
"""
N = 1000
states = [(node, False) for node in G.nodes()]
t2_last = 0.0
for i in xrange(N):
if i==0: #assign random states
states = [(state[0], True) for state in states if rand(1)>.5]
sub_nodes = [state[0] for state in states if state[1]]
Gsub = NX.subgraph(G, sub_nodes)
Gsub = NX.connected_components_subgraphs(Gsub)[0]
t2 = [T2[node] for node in Gsub]
if t2>t2_last:
pass
else:
p = numpy.exp()
"""Below are methods for calculating graph metrics
Four main decompositions :
0.) Adjacency diffusion kernel expm(A),
1.) von neumann kernels (diagonalisation of adjacency matrix)
2.) laplacian kernels (geometric series of adj.)
3.) diffusion kernels (exponential series of adj.)
---- Kv
von_neumann : Kv = (I-alpha*A)^-1 (mod: A(I-alpha*A)^-1)? ,
geom. series
---- Kl
laplacian: Kl = (I-alpha*L)^-1 , geom. series
---- Kd