forms.form
¶
Module Contents¶
Classes¶
The basic form object. |
-
class
forms.form.
Form
(ctx: commands.Context, title)¶ Bases:
object
The basic form object.
-
set_timeout
(self, timeout: int) → None¶ Sets the timeout for the form.
- Parameters
(int) (timeout) –
-
set_tries
(self, tries: int) → None¶
-
add_question
(self, question, key: str = None, qtype=None) → List[dict]¶ Adds a question to the form.
- Parameters
question (str) – The question as a string that should be added.
key (str, optional) – The prefered key to be used. If none, defaults to the to the question. By default None.
qtype (str, optional) – The input validation to be used (incomplete), by default None
- Returns
A list of all of the questions, stored as dictionaries.
- Return type
List[dict]
- Raises
InvalidFormType – Is raised when the input validation type is invalid.
-
async
validate_input
(self, qtype, answer)¶
-
edit_and_delete
(self, choice: bool = None) → bool¶ Toggles the edit and delete feature.
- Parameters
choice (bool, optional) – Whether you want the bot to edit the prompt and delete the input or not. If none, it toggles. The default for edit and delete is off. Default input is None
- Returns
The state of edit and delete (after this is completed)
- Return type
bool
-
set_retry_message
(self, message: str)¶ Sets the message to send if input validation fails.
- Parameters
message (str) – The message to be set.
-
set_incorrect_message
(self, message: str)¶ Sets the message to send if input validation fails and there are no more tries left..
- Parameters
message (str) – The message to be set.
-
async
set_color
(self, color: str) → None¶ Sets the color of the form embeds.
-
async
start
(self, channel=None) → List[dict]¶ Starts the form in the current channel.
- Parameters
channel (discord.TextChannel, optional) – The channel to open the form in. If none, it is gotten from the context object set during initialization.
- Returns
[description]
- Return type
List[dict]
-
-
exception
forms.form.
InvalidColor
¶ Bases:
Exception
Common base class for all non-exit exceptions.
-
exception
forms.form.
InvalidFormType
¶ Bases:
Exception
The exception raised when a form type is invalid.


class: center, middle, title-slide count: false # Lesson 5 ## Datasets, dataloaders ## and Embeddings
.bold[Marc Lelarge] --- # Deep Learning pipeline ## .red[Dataset and Dataloader] + .grey[Model] + .grey[Loss and Optimizer] = .grey[Training] .center[
] --- # Overview of the course: 1- .grey[Course overview: machine learning pipeline] 2- .grey[PyTorch tensors and automatic differentiation] 3- .grey[Classification with deep learning] 4- .grey[Convolutional neural networks] 5- Embedding layers and dataloaders * .red[Building block for a model] - in Pytorch: [Sparse layers](https://pytorch.org/docs/stable/nn.html#sparse-layers) * .red[Datasets and dataloaders] - in PyTorch: [`torch.utils.data`](https://pytorch.org/docs/stable/data.html) --- # Dataloading -- count: false ## Dataset class `torch.utils.data.Dataset` is an abstract class representing a dataset. Your custom dataset should inherit `Dataset` and override the following methods: - `__len__` so that `len(dataset)` returns the size of the dataset. - `__getitem__` to support the indexing such that `dataset[i]` can be used to get ith sample -- count: false ## Iterating through the dataset with `Dataloader` By using a simple `for` loop to iterate over the data, we are missing out on: - Batching the data - Shuffling the data - Load the data in parallel using multiprocessing workers. `torch.utils.data.DataLoader` is an iterator which provides all these features. --- ## Examples (1) In the first lesson, we created two datasets, one for the training and one for the validation: ``` from torchvision import transforms,datasets normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) imagenet_format = transforms.Compose([transforms.CenterCrop(224), transforms.ToTensor(), normalize]) dsets = {x: datasets.ImageFolder(os.path.join(data_dir, x), imagenet_format) for x in ['train', 'valid']} ``` Hence `len(dsets['train'])` returns `23000`, i.e. the number of images in the training set, and more precisely, the number of files located at `data_dir/train/`. Recall that `data_dir/train/` (and similarly `data_dir/valid/`) is split in two folders: `cats/` and `dogs/`, you can check that each of these folders have `11500` images with: `ls | wc -l` You can recover the classes with `dsets['train'].classes` which returns `['cats', 'dogs']` These are features of the [`torchvision.datasets.ImageFolder`](https://pytorch.org/docs/stable/torchvision/datasets.html?highlight=imagefolder#torchvision.datasets.ImageFolder) Module. -- count: false More importantly, what returns `dsets['train'][0]`? -- count: false Answer: a tuple containing a tensor and a label. --- ## Examples (1) To obtain a dataloader for the training set: ``` train_loader = torch.utils.data.DataLoader(dsets['train'], batch_size=64, shuffle=True, num_workers=6) ``` -- count: false Then, you can use it as follows: ``` for input, label in train_loader: output = model(input) loss = loss_fn(output, label) optimizer.zero_grad() loss.backward() optimizer.step() ....``` --- ## Examples (2) In the first lesson, we first precomputed features and converted them as `numpy` arrays. You first need to load the features and the labels: ``` conv_feat_train,labels_train = preconvfeat(loader_train) ``` and then, you can create a list for your dataset as follows: ``` dtype=torch.float datasetfeat_train = [[torch.from_numpy(f).type(dtype),torch.tensor(l).type(torch.long)] for (f,l) in zip(conv_feat_train,labels_train)] datasetfeat_train = [(inputs.reshape(-1), classes) for [inputs,classes] in datasetfeat_train] ``` A list has a buil-in function `len()` and a `__getitem__()` method, hence this is a valid dataset for PyTorch. -- count: false To create a dataloader, it is as simple as: ``` loaderfeat_train = torch.utils.data.DataLoader(datasetfeat_train, batch_size=128, shuffle=True) ``` --- ## Examples (3) Today, we will make our own dataloader from scratch using a Python iterator: .grid[ .kol-6-12[ .left[ ``` def minibatch(batch_size, *tensors): if len(tensors) == 1: tensor = tensors[0] for i in range(0, len(tensor), batch_size): yield tensor[i:i + batch_size] else: for i in range(0, len(tensors[0]), batch_size): yield tuple(x[i:i + batch_size] for x in tensors) ```]] .kol-6-12[.left[ ``` def shuffle(*arrays): random_state = np.random.RandomState() shuffle_indices = np.arange(len(arrays[0])) random_state.shuffle(shuffle_indices) if len(arrays) == 1: return arrays[0][shuffle_indices] else: return tuple(x[shuffle_indices] for x in arrays)```]]] -- count: false We will use it as follows (inside an epoch): ``` users, items, ratingss = shuffle(user_ids,item_ids,ratings) user_ids_tensor = torch.from_numpy(users).to(device) item_ids_tensor = torch.from_numpy(items).to(device) ratings_tensor = torch.from_numpy(ratingss).to(device) for (minibatch_num, (batch_user,batch_item,batch_rating)) in enumerate(minibatch(batch_size, user_ids_tensor,item_ids_tensor,ratings_tensor)): predictions = net(batch_user, batch_item) ... ``` --- ## To know more about dataloading have a look at the related [PyTorch tutorial](https://pytorch.org/tutorials/beginner/data_loading_tutorial.html) --- # Deep Learning pipeline ## .red[Dataset and Dataloader] + .grey[Model] + .grey[Loss and Optimizer] = .grey[Training] ## Now: how to deal with symbolic data like ids? .center[
] --- # One-hot encoding Encoding colors: .center.width-40[![](images/lesson5/one-hot.jpg)] Why not simply use: blue = 0, red = 1 and so on? What are the Pros/Cons of such a representation? -- count: false - Each axis has a meaning - Sparse, discrete representation with large dimension (size of the vocabulary). - Symbols are equidistant from each other with euclidean distance $\sqrt{2}$ for large vocabulary. --- # Embeddings Idea: project in $\mathbb{R}^d$ with $d$ much smaller than the size $n$ of the vocabulary! -- count: false More formaly, let $W\in \mathbb{R}^{n\times d}$, we define $$ \text{embedding}(x) = \text{onehot}(x) W $$ $W$ is typically randomly initialized, then tuned by backprop. $W$ are trainable parameters of the model. -- count: false - Continuous and dense representation. - Can represent a huge vocabulary in low dimension. - Axis have no meaning a priori but once trained, embedding metric can capture semantic distance. --- # Example: embeddings for movies in recommender systems .center.width-50[![](images/lesson5/embedding.png)] PCA of embeddings for movies learned in the practical of this lesson. --- ## Embeddings in PyTorch [Sparse layers](https://pytorch.org/docs/master/nn.html#embedding) in PyTorch: `torch.nn.Embedding(num_embeddings, embedding_dim)` Example: creating embeddings for users ``` embedding_dim = 3 embedding_user = nn.Embedding(total_user_id, embedding_dim) input = torch.LongTensor([[1,2,4,5],[4,3,2,0]]) embedding_user(input) ``` -- count: false returns ``` tensor([[[-1.7219, 0.4682, 0.5729], [ 0.0657, -0.7046, -0.4397], [ 1.1512, 1.3380, -1.0272], [ 1.4405, 1.2945, 1.0051]], [[ 1.1512, 1.3380, -1.0272], [-0.6698, -2.1828, -0.1695], [ 0.0657, -0.7046, -0.4397], [-0.7966, -1.6769, -0.7454]]]) ``` -- count: false So now it's time to play with embeddings, [here](https://colab.research.google.com/github/mlelarge/dataflowr/blob/master/PlutonAI/05_collaborative_filtering_PlutonAI_colab_empty.ipynb)! --- class: end-slide, center count: false The end.


You tried to upload the wrong file type. You can only upload '.jpg', '.jpeg', '.png', or '.pdf' files.


--- layout: post title: "Ad-hoc Arbitraries - now with pipes" description: "Slightly improved syntax for defining ad-hoc, in-line Arbitraries for FsCheck.Xunit." date: 2016-03-01 08:46 UTC tags: [Unit Testing, xUnit.net, F#, FsCheck] --- {% include JB/setup %}
{{ page.description }}
Last year, I described how to define and use ad-hoc, in-line Arbitraries with FsCheck.Xunit. The final example code looked like this:
[<Property(QuietOnSuccess = true)>] let ``Any live cell with > 3 live neighbors dies`` (cell : int * int) = let nc = Gen.elements [4..8] |> Arb.fromGen Prop.forAll nc (fun neighborCount -> let liveNeighbors = cell |> findNeighbors |> shuffle |> Seq.take neighborCount |> Seq.toList let actual : State = calculateNextState (cell :: liveNeighbors |> shuffle |> set) cell Dead =! actual)
There's one tiny problem with this way of expressing properties using Prop.forAll: the use of brackets to demarcate the anonymous multi-line function. Notice how the opening bracket appears to the left of the fun
keyword, while the closing bracket appears eleven lines down, after the end of the expression Dead =! actual
.
While it isn't pretty, I haven't found it that bad for readability, either. When you're writing the property, however, this syntax is cumbersome.
After having written Prop.forAll nc
, you start writing (fun neighborCount -> )
. After you've typed the closing bracket, you have to move your cursor one place to the left. When entering new lines, you have to keep diligent, making sure that the closing bracket is always to the right of your cursor.
If you ever need to use a nested level of brackets within that anonymous function, your vigilance will be tested to its utmost. When I wrote the above property, for example, when I reached the point where I wanted to call the calculateNextState function, I wrote:
let actual : State =
calculateNextState (
The editor detects that I'm writing an opening bracket, but since I have the closing bracket to the immediate right of the cursor, this is what happens:
let actual : State =
calculateNextState ()
What normally happens when you type an opening bracket is that the editor automatically inserts a closing bracket to the right of your cursor, but in this case, it doesn't do that. There's already a closing bracket immediately to the right of the cursor, and the editor assumes that this bracket belongs to the opening bracket I just typed. What it really should have done was this:
let actual : State = calculateNextState ())
The editor doesn't have a chance, though, because at this point, I'm still typing, and the code doesn't compile. None of the alternatives compile at this point. You can't really blame the editor.
To make a long story short, enclosing a multi-line anonymous function in brackets is a source of errors. If only there was a better alternative.
The solution started to dawn on me because I've been learning Haskell for the last half year, and in Haskell, you often use the $
operator to get rid of unwanted brackets. F# has an equivalent operator: <|
, the backward pipe operator.
I rarely use the <|
operator in F#, but in this case, it works really well:
[<Property(QuietOnSuccess = true)>] let ``Any live cell with > 3 live neighbors dies`` (cell : int * int) = let nc = Gen.elements [4..8] |> Arb.fromGen Prop.forAll nc <| fun neighborCount -> let liveNeighbors = cell |> findNeighbors |> shuffle |> Seq.take neighborCount |> Seq.toList let actual : State = calculateNextState (cell :: liveNeighbors |> shuffle |> set) cell Dead =! actual
Notice that there's no longer any need for a closing bracket after Dead =! actual
.
When the last argument passed to a function is another function, you can replace the brackets with a single application of the <|
operator. I only use this operator sparingly, but in the case of in-line ad-hoc FsCheck Arbitraries, I find it useful.
Addendum 2016-05-17: You can get rid of the nc
value with TIE fighter infix notation.


Rag 18 Reloaded
{{discipline}} Discipline
Creative Animated Loading icon in HTML5 CSS3
{{student["Student ID"]}} - {{student.Name}}


This is an example how to install Nginx by Chef. Previously I have written article how to install Chef on Ubuntu and now we will try to install the first cookbook on this environment.
1. Download cookbook
Create cookbook directory:
sudo mkdir -p /var/chef/cookbooks
sudo chown ubuntu:ubuntu /var/chef/cookbooks
cd /var/chef/cookbooks
git init
echo "This is a cookbooks directory" > readme.txt
git add *
git commit -m "init master"
Download “nginx” cookbook and place it in /var/chef/cookbooks directory with dependencies:
knife cookbook site install nginx
Fix types_hash_max_size:
nano /var/chef/cookbooks/nginx/templates/default/nginx.conf.erb
Put in bottom of the http section the text:
types_hash_max_size 8192;
Upload cookbooks to the Chef Server
knife cookbook upload ohai
knife cookbook upload build-essential
knife cookbook upload yum
knife cookbook upload bluepill
knife cookbook upload runit
knife cookbook upload nginx
List active nodes
knife node list
Select front node and apply recipe for it
knife node run_list add front_node 'nginx::default'
Show the node to ensure that the run_list contains the recipe
knife node show front_node
Chef WebUI customization
/usr/share/chef-server-webui/config/rack.rb
use Rack::ContentLength
if prefix = ::Merb::Config[:path_prefix]
use Merb::Rack::PathPrefix, prefix
end
use Merb::Rack::Static, Merb.dir_for(:public)
run Merb::Rack::Application.new
add to /usr/share/chef-server-webui/config/environments/production.rb:
c[:path_prefix] = ‘/webui’


${include:query.html} ${include:database.html} ${include:server.html} ${include:cluster.html} ${include:api.html} ${include:resources.html}
×
${include:popup-login.html}
Copyright 2021
Arcade Data Ltd


Post
Archive
Back
Product Code
status
Create New Item
Map to Existing Item
Item type
Item Name/Number
Description on Purchase Transactions:
Cost :
Sales Information:
Sales Price:
Manufacturer's Part Number
Tax Code:
COGS Account:
Income Account:
Preferred Vendor:
Save Item
Map Product
to
Map Item
Refresh Products From QB
A product refresh job is currently running.
Refresh status


Warehouse Keeper Ballin: Welcome, youngster. You seem to be doing very well for yourself. Ever consider depositing some of your items instead of carrying them around like that man over there? He looks like a peddler! No, clearly we offer a better, safer alternative here at the Steel Gate Guild. And once you deposit an item, you can withdraw it at any of our branches! For the sake of security, of course, only the people you designate can do so.


Author: Wolf-Dieter Fink
Level: Advanced
Technologies: EJB, HASingleton, JNDI, Clustering, MSC
Summary: The cluster-ha-singleton
quickstart deploys a Service, wrapped with the SingletonService decorator, and used as a cluster-wide singleton service.
Target Product: JBoss EAP
Source: https://github.com/jbossas/eap-quickstarts/
The cluster-ha-singleton
quickstart demonstrates the deployment of a Service that is wrapped with the
SingletonService decorator and used as a cluster-wide singleton service in Red Hat JBoss Enterprise Application Platform.
The service activates a scheduled timer, which is started only once in the cluster.
The example is composed of a Maven subproject and a parent project. The projects are as follows:
service
: This subproject contains the Service and the EJB code to instantiate, start, and access the service.pom.xml
builds the service
subproject and deploys the archive to the server.The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 7.1 or later.
All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.2.5 or later. See Configure Maven for JBoss EAP 7.1 to make sure you are configured correctly for testing the quickstarts.
In the following instructions, replace EAP7_HOME
with the actual path to your JBoss EAP installation. The installation path is described in detail here: Use of EAP7_HOME and JBOSS_HOME Variables.
While you can run this example starting only one instance of the server, if you want to see the singleton behavior, you must start at least two instances of the server. Make a copy of the JBoss EAP directory structure to use for the second server.
Note: You must start the server using the HA profile or the singleton service will not start correctly.
Start the two JBoss EAP servers with the HA profile by typing the following commands. You must pass a socket binding port offset on the command to start the second server.
If you are using Linux:
Server 1: EAP7_HOME_1/bin/standalone.sh --server-config=standalone-ha.xml
Server 2: EAP7_HOME_2/bin/standalone.sh --server-config=standalone-ha.xml -Djboss.socket.binding.port-offset=100
If you are using Windows
Server 1: EAP7_HOME_1\bin\standalone.bat --server-config=standalone-ha.xml
Server 2: EAP7_HOME_2\bin\standalone.bat --server-config=standalone-ha.xml -Djboss.socket.binding.port-offset=100
Note: If you want to test with more than two servers, you can start additional servers by specifying a unique port offset for each one.
mvn clean install wildfly:deploy
This deploys service/target/cluster-ha-singleton-service.jar
to the running instance of the first server.
9990
and the second server runs at a port offset of 100
, you must pass port 10090
(9990 + 100) as an argument when you deploy to the second server. Type this command to deploy the archive to the second server.
mvn wildfly:deploy -Dwildfly.port=10090
If the second server is on a different host, you must also pass an argument for the host name as follows:
mvn wildfly:deploy [-Dwildfly.hostname=OTHERHOST] -Dwildfly.port=10090
Note: If you test with more than two servers, repeat the command, replacing the unique port offset for each server.
service/target/cluster-ha-singleton-service.jar
to the running instance of the additional server.To verify the application deployed to each server instance, check the server logs. The first instance should have the following message:
INFO [org.wildfly.clustering.server] (remote-thread--p2-t1) WFLYCLSV0003: localhost elected as the singleton provider of the jboss.quickstart.ha.singleton.timer service
The first server instance will also have messages like the following:
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 4) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 5) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
The other servers will have the message:
WFLYSRV0010: Deployed "cluster-ha-singleton-service.jar" (runtime-name : "cluster-ha-singleton-service.jar")
NOTE: You will see the following warnings in both server logs when you deploy the application. You can ignore them.
WARN [org.jgroups.protocols.UDP] (MSC service thread 1-6) JGRP000015: the send buffer of socket ManagedDatagramSocketBinding was set to 1MB, but the OS only allocated 212.99KB. This might lead to performance problems. Please set your max send buffer in the OS correctly (e.g. net.core.wmem_max on Linux)
WARN [org.jgroups.protocols.UDP] (MSC service thread 1-6) JGRP000015: the receive buffer of socket ManagedDatagramSocketBinding was set to 20MB, but the OS only allocated 212.99KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux)
WARN [org.jgroups.protocols.UDP] (MSC service thread 1-6) JGRP000015: the send buffer of socket ManagedMulticastSocketBinding was set to 1MB, but the OS only allocated 212.99KB. This might lead to performance problems. Please set your max send buffer in the OS correctly (e.g. net.core.wmem_max on Linux)
WARN [org.jgroups.protocols.UDP] (MSC service thread 1-6) JGRP000015: the receive buffer of socket ManagedMulticastSocketBinding was set to 25MB, but the OS only allocated 212.99KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux)
The timer started on the server instance will log a message every 10 seconds. If you stop the EAP7_HOME_1
server, you see messages in the EAP7_HOME_2
server console indicating it is now the singleton provider.
WFLYCLSV0003: localhost elected as the singleton provider of the jboss.quickstart.ha.singleton.timer service
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.HATimerService] (MSC service thread 1-5) Start HASingleton timer service 'org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.HATimerService'
INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (Incoming-2,ee,localhost) ISPN000094: Received new cluster view for channel server: [localhost|2] (1) [localhost]
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 1) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 2) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
In the example, the EAP7_HOME_1
instance used as master, if it is available. If it has failed or shutdown, any other service instance will be used.
mvn wildfly:undeploy
mvn wildfly:undeploy [-Dwildfly.hostname=OTHERHOST] -Dwildfly.port=10090
NOTE: You may see the following error in the server log when you undeploy the application. You can ignore this error. For performance reasons, the server does not wait for tasks to complete when an application is undeployed,
ERROR [org.jboss.as.ejb3.invocation] (MSC service thread 1-7) WFLYEJB0034: EJB Invocation failed on component SchedulerBean for method public abstract void org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.Scheduler.stop(): org.jboss.as.ejb3.component.EJBComponentUnavailableException: WFLYEJB0421: Invocation cannot proceed as component is shutting down
You can also start the server and deploy the quickstarts or run the Arquillian tests from Eclipse using JBoss tools. For general information about how to import a quickstart, add a JBoss EAP server, and build and deploy a quickstart, see Use JBoss Developer Studio or Eclipse to Run the Quickstarts.
This quickstart is more complex than the others. It requires that you configure and run two instances of the JBoss EAP server, so it deploys and runs differently in JBoss Developer Studio than the other quickstarts.
NOTE: If you have not yet configured the JBoss EAP 7.1 runtime in JBoss Developer Studio, choose Window
--> Preferences
--> Runtime Environment
and click Add
to configure the following server instances.
Server
tab, right-click and choose New
--> Server
.Select the server type:
, expand Red Hat JBoss Middleware
and choose Red Hat JBoss Enterprise Application Platform 7.x
.Server name
, enter EAP7-Server1
and click Next
.Create a new Server Adapter
dialog, choose Create a new runtime (next page)
and click Next
.JBoss Runtime
dialog, enter the following information and then click Next
.
Name: EAP7-Server1
Home Directory: (Browse to the directory for the first server and select it)
Execution Environment: (Choose your JRE 8 runtime if not correct)
Configuration base directory: (This should already point to your server configuration directory)
Configuration file: (Browse and choose the `standalone-ha.xml` file)
Add and Remove
dialog, add the cluster-ha-singleton-service
to the Configured
list and click Finished
.Server
tab, right-click and choose New
--> Server
.Select the server type:
, expand Red Hat JBoss Middleware
and choose Red Hat JBoss Enterprise Application Platform 7.x
.Server name
, enter EAP7-Server2
and click Next
.Create a new Server Adapter
dialog, choose Create a new runtime (next page)
and click Next
.JBoss Runtime
dialog, enter the following information and then click Next
.
Name: EAP7-Server2
Home Directory: (Browse to the cloned directory for the second server and select it)
Execution Environment: (Choose your JRE 8 runtime if not correct)
Configuration base directory: (This should already point to your cloned server configuration directory)
Configuration file: (Browse and choose the `standalone-ha.xml` file)
Add and Remove
dialog, add the cluster-ha-singleton-service
to the Configured
list and click Finished
.Server
tab, double-click on EAP7-Server2
to open the Overview
page.Open launch configuration
and at the end of the VM Arguments
, paste -Djboss.socket.binding.port-offset=100
and click OK
.Overview
page for EAP7-Server2
, under Server Ports
, uncheck the Detect from Local Runtime
next to Port Offset
and enter 100
. Save the changes using the menu File --> Save
To deploy the cluster-ha-singleton service to EAP7-Server1
, right-click on the cluster-ha-singleton-service
project, choose Run As
--> Run on Server
, choose EAP7-Server1
and click Finish
. Note the messages in the EAP7-Server1
server console indicate it is the singleton provider of the service.
WFLYCLSV0003: localhost elected as the singleton provider of the jboss.quickstart.ha.singleton.timer service
WFLYSRV0060: Http management interface listening on http://<IP_ADDRESS>:9990/management
WFLYSRV0051: Admin console listening on http://<IP_ADDRESS>:9990
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 1) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 2) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 3) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
To deploy the cluster-ha-singleton service to EAP7-Server2
, right-click on the cluster-ha-singleton-service
project, choose Run As
--> Run on Server
, choose EAP7-Server2
and click Finish
. Note that EAP7-Server1
is still the singleton provider of the service. This message is in the EAP7-Server2
console.
WFLYSRV0060: Http management interface listening on http://<IP_ADDRESS>:10090/management
Stop the EAP7-Server1
server and note the following message in the EAP7-Server2
server console indicating it is now the singleton provider.
WFLYCLSV0003: localhost elected as the singleton provider of the jboss.quickstart.ha.singleton.timer service
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 1) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 2) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
INFO [class org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.SchedulerBean] (EJB default - 3) HASingletonTimer: Info=HASingleton timer @localhost <timestamp>
If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it.
mvn dependency:sources


Feature Extraction¶
length¶
protlearn.features.length(X, *, method='int')
Sequence length in amino acids.
The number of amino acids that a protein or peptide is comprised of will be counted and returned as either an integer (single sequence), array of integers, or a one-hot-encoded array.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- method: string, default=’int’
‘int’ : interval data
‘ohe’ : one-hot encoded data
Returns¶
- arr: int or ndarray of shape (n_samples, ) or (n_samples, n_unique_lengths)
Array containing sequence lengths.
Examples¶
>>> from protlearn.features import length
>>> seqs = ['ARKLY', 'EERKPGL', 'LLYPGP']
>>> l_int = length(seqs)
>>> l_int
array([5, 7, 6])
>>> l_ohe = length(seqs, method='ohe')
array([[1., 0., 0.],
[0., 0., 1.],
[0., 1., 0.]])
aac¶
protlearn.features.aac(X, *, method='relative', start=1, end=None)
Amino acid composition.
This function returns the frequency of amino acids for each sequence in the dataset.
aac is calculated as follows:
where i denotes the 20 amino acid residues, ni is the frequency of each residue i, and N is the total number of residues in the sequence.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- method: string, default=’relative’
‘absolute’ : absolute amino acid composition
‘relative’ : relative amino acid composition- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, n_unique_amino_acids)
Array containing the amino acid composition.
- amino_acids: string
Corresponds to the columns (amino acids) in arr.
Examples¶
>>> from protlearn.features import aac
>>> seqs = ['ARKLY', 'EERKPGL']
>>> comp, aa = aac(seqs)
>>> comp
array([[0.2 , 0. , 0. , 0.2 , 0.2 ,
0. , 0.2 , 0.2 ],
[0. , 0.28571429, 0.14285714, 0.14285714, 0.14285714,
0.14285714, 0.14285714, 0. ]])
>>> aa
'AEGKLPRY'
Note that columns containing all zeros have been removed from the final array.
aaindex1¶
protlearn.features.aaindex1(X, *, standardize='none', start=1, end=None)
AAIndex1-based physicochemical properties.
AAindex1 ver.9.2 (release Feb, 2017) is a set of 20 numerical values representing various physicochemical and biological properties of amino acids. Currently, it contains 566 indices, of which 553 contain no NaNs. The indices will be collected for each amino acid in the sequence, then averaged across the sequence.
aaindex1 is calculated as follows:
where i denotes the 566 AAIndex1 indices, aan denotes the amino acid at position n, and N is the total number of residues in the sequence.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- standardize: string, default=’none’
‘none’ : unstandardized index matrix will be returned
‘zscore’ : index matrix is standardized to have a mean of 0 and standard deviation of 1.
‘minmax’ : index matrix is normalized to have a range of [0, 1].- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 553-566)
Array containing the AAIndex1 physicochemical properties.
- desc: list of length 553-566
Corresponds to the columns (AAIndices) in arr.
Notes¶
Columns (indices) containing NaNs will be removed. Thus, the resulting index matrix will have a column size between 553-566.
References¶
Nakai, K., Kidera, A., and Kanehisa, M.; Cluster analysis of amino acid indices for prediction of protein structure and function. Protein Eng. 2, 93-100 (1988). [PMID:3244698]
Tomii, K. and Kanehisa, M.; Analysis of amino acid indices and mutation matrices for sequence comparison and structure prediction of proteins. Protein Eng. 9, 27-36 (1996). [PMID:9053899]
Kawashima, S., Ogata, H., and Kanehisa, M.; AAindex: amino acid index database. Nucleic Acids Res. 27, 368-369 (1999). [PMID:9847231]
Kawashima, S. and Kanehisa, M.; AAindex: amino acid index database. Nucleic Acids Res. 28, 374 (2000). [PMID:10592278]
Kawashima, S., Pokarowski, P., Pokarowska, M., Kolinski, A., Katayama, T., and Kanehisa, M.; AAindex: amino acid index database, progress report 2008. Nucleic Acids Res. 36, D202-D205 (2008). [PMID:17998252]
Examples¶
>>> from protlearn.features import aaindex1
>>> seqs = ['ARKLY', 'EERKPGL']
>>> aaind, inds = aaindex1(seqs, standardize='zscore')
>>> aaind.shape
(2, 553)
>>> len(inds)
553
ngram¶
protlearn.features.ngram(X, *, method='relative', start=1, end=None)
N-gram composition.
This function computes the di- or tripeptide composition of amino acid sequences. Therefore, the function parameter n can only take on the arguments 2 and 3 - otherwise, it will raise a ValueError.
ngram is calculated as follows:
where Nij and Nijk denote the di- and tripeptides comprised by amino acids ij and ijk, respectively. N denotes the total sequence length.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- n: int, default=2
Integer denoting the desired n-gram composition.
2 : dipeptide composition
3 : tripepitde composition- method: string, default=’relative’
‘absolute’: absolute n-gram composition
‘relative’: relative n-gram composition- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, n_unique^n)
Depending on n, the returned array will be of size:
- (n_samples, 400) for dipeptide composition
- (n_samples, 8000) for tripeptide composition
if all possible n-gram combinations are represented.- n-grams: list of length n_unique^n
List of n-grams corresponding to columns in arr.
Examples¶
>>> from protlearn.features import ngram
>>> seqs = ['ARKLY', 'EERKPGL']
>>> di, ngrams = ngram(seqs, n=2)
>>> di
array([[0.25 , 0.25 , 0.25 , 0.25 , 0. ,
0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0.16666667, 0.16666667,
0.16666667, 0.16666667, 0.16666667, 0.16666667]])
>>> ngrams
['AR', 'KL', 'LY', 'RK', 'EE', 'ER', 'GL', 'KP', 'PG']
>>> tri, ngrams = ngram(seqs, n=3)
array([[0.33333333, 0.33333333, 0.33333333, 0. , 0. ,
0. , 0. , 0. ],
[0. , 0. , 0. , 0.2 , 0.2 ,
0.2 , 0.2 , 0.2 ]])
>>> ngrams
['ARK', 'KLY', 'RKL', 'EER', 'ERK', 'KPG', 'PGL', 'RKP']
entropy¶
protlearn.features.entropy(X, *, standardize='none', start=1, end=None)
Shannon entropy.
This function computes the Shannon entropy for each sequence in the dataset as follows:
where i denotes the 20 amino acids and P(xi) denotes the probability of a given amino acid in the sequence.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- standardize: string, default=’none’
‘none’ : unstandardized matrix will be returned
‘zscore’ : matrix is standardized to have a mean of 0 and standard deviation of 1.
‘minmax’ : matrix is normalized to have a range of [0, 1].- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples,) if len(X) > 1, otherwise float
Array containing Shannon entropy values for each sequence.
Examples¶
>>> from protlearn.features import entropy
>>> seqs = ['ARKLY', 'EERKPGL', 'AAAAAALY']
>>> ent = entropy(seqs)
>>> ent
array([2.32192809, 2.52164064, 0.64020643])
posrich¶
protlearn.features.posrich(X, *, position, aminoacid)
Position-specific amino acids.
This function returns a binary vector or matrix in which ones indicate the presence of the given amino acid(s) at the specified position(s), and zeros indicate their absence.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- position: int or list
Integer or list of integers denoting the position(s) in the sequence.
- aminoacid: string or list
String or list of strings indicating the amino acid(s) of interest.
Returns¶
- arr: ndarray of shape (n_samples, ) or (n_samples, n_positions)
Binary vector/matrix indicating position-specific presence of amino acids.
Notes¶
The position argument is based on one-based indexing.
Examples¶
>>> from protlearn.features import posrich
>>> seqs = ['ARKLY', 'ERNLAPG', 'YRLQLLLY']
>>> pos_single = posrich(seqs, position=4, aminoacid='L')
>>> pos_single
array([1., 1., 0.])
>>> pos_multiple = posrich(seqs, position=[2,3,4], aminoacid=['R','N','L'])
array([[1., 0., 1.],
[1., 1., 1.],
[1., 0., 0.]])
motif¶
protlearn.features.motif(X, pattern, *, start=1, end=None)
Sequence motifs.
This function returns a binary vector indicating the presence of a specified amino acid sequence motif.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- pattern: string
Represents the sequence motif.
x –> any amino acid
[XY] –> X or Y
{X} –> any amino acid except X- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples,)
Binary vector indicating the presence of the motif in sequences.
Examples¶
>>> from protlearn.features import motif
>>> seqs = ['AARKYLL', 'LELCDPGPG', 'RAAANCDD']
>>> pattern1 = pattern = 'AAx[KC]'
>>> m1 = motif(seqs, pattern1)
>>> m1
array([1., 0., 1.])
>>> pattern2 = 'xxC[DA]xx{Y}'
>>> m2 = motif(seqs, pattern2)
>>> m2
array([0., 1., 0.])
Based on the example above, ‘pattern1’ is interpreted as follows: Two consecutive amino acids ‘A’, followed by any amino acid, followed by either a ‘K’ or a ‘C’.
Likewise, pattern2 is interpreted as follows: Any two consecutive amino acids, followed by a ‘C’, followed by either a ‘D’ or an ‘A’, followed by any two amino acids, followed by any amino acid except ‘Y’.
atc¶
protlearn.features.atc(X, *, method='relative', start=1, end=None)
Atomic and bond composition.
This function returns the sum of atomic and bond compositions for each amino acid sequence. The atomic features are comprised of five atoms (C, H, N, O, and S), and the bond features are comprised of total bonds, single bonds, and double bonds.
atc is calculated as follows:
where i denotes the type of atoms, ni is the total number of atoms of type i, and N is the total number of atoms in the sequence.
where j denotes the type of bond and nj is the total number of bonds of type j.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- method: string, default=’relative’
‘absolute’: absolute atomic composition
‘relative’: relative atomic composition- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr_atoms: ndarray of shape (n_samples, 5)
Array containing atomic compositions.
- arr_bonds: ndarray of shape (n_samples, 3)
Array containing bond compositions.
Notes¶
The method
argument only applies to the atomic composition, not
the bond composition.
References¶
Kumar, R., Chaudhary, K., Singh Chauhan, J. et al. An in silico platform for predicting, screening and designing of antihypertensive peptides. Sci Rep 5, 12512 (2015). https://doi.org/10.1038/srep12512
Examples¶
>>> from protlearn.features import atc
>>> seqs = ['ARKLY', 'EERKPGL', 'AAAAAALY']
>>> atoms, bonds = atc(seqs)
>>> atoms
array([[0.27522936, 0.5412844 , 0.08256881, 0.10091743, 0.],
[0.25547445, 0.53284672, 0.08029197, 0.13138686, 0.],
[0.26612903, 0.53225806, 0.06451613, 0.13709677, 0.]])
>>> bonds
array([[105., 96., 9.],
[131., 121., 10.],
[117., 106., 11.]])
binary¶
protlearn.features.binary(X, *, padding=True, start=1, end=None)
Binary profile pattern.
This function returns the binary profile pattern for each amino acid sequence in the dataset. The output array is therefore very sparse, as each amino acid is represented by a 20-dimensional vector with only one non-zero value.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- padding: bool, default=True
Pad sequences of unequal lengths with zeros at the posterior end.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 20*seq_length)
Array containing binary profile pattern.
Notes¶
This function is intended for proteins or peptides with equal lengths only.
References¶
Ansari, H. R., & Raghava, G. P. (2010). Identification of conformational B-cell Epitopes in an antigen from its primary sequence. Immunome research, 6, 6. https://doi.org/10.1186/1745-7580-6-6
Chen Z, Chen Y-Z, Wang X-F, Wang C, Yan R-X, Zhang Z (2011) Prediction of Ubiquitination Sites by Using the Composition of k-Spaced Amino Acid Pairs. PLoS ONE 6(7): e22930. https://doi.org/10.1371/journal.pone.0022930
Examples¶
>>> from protlearn.features import binary
>>> seqs = ['ARKLY', 'EERKPGL']
>>> bpp = binary(seqs, padding=True)
>>> bpp
array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
cksaap¶
protlearn.features.cksaap(X, *, k=1, start=1, end=None)
Composition of k-spaced amino acid pairs.
This function returns the k-spaced amino acid pair composition of each sequence in the dataset. Since there are 20 natural amino acids, there are 400 possible amino acid pairs. The parameter ‘k’ represents the gap between the amino acid pair. An example for k=1 would be AxY, where ‘x’ can be any amino acid. Similary, an example for k=2 would be AxxY. If k=0, the function returns the dipeptide composition of each sequence.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- lambda_: int, default=1
Counted rank (tier) of the correlation along an amino acid sequence.
- k: int, default=1
Space between two amino acid pairs.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 400)
Array containing k-spaced amino acid pair composition.
- patterns: list of length 400
Amino acid pairs with k gaps corresponding to columns in arr.
Notes¶
Columns containing only zeros will be deleted. Therefore, the returned array and list may have a lower dimensionality than 400, depending on the unique number of k-spaced amino acid pairs in the dataset.
References¶
Chen, K., Kurgan, L.A. & Ruan, J. Prediction of flexible/rigid regions from protein sequences using k-spaced amino acid pairs. BMC Struct Biol 7, 25 (2007). https://doi.org/10.1186/1472-6807-7-25
Examples¶
>>> from protlearn.features import cksaap
>>> seqs = ['ARKLY', 'EERKPGL', 'AAAAAALY']
>>> ck, pairs = cksaap(seqs)
>>> ck
array([[0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0],
[0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1],
[4, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0]])
>>> pairs
['A.A', 'A.K', 'A.L', 'A.Y', 'E.K', 'E.R', 'K.G', 'K.Y', 'P.L', 'R.L', 'R.P']
>>> ck2, pairs2 = cksaap(seqs, k=2)
>>> ck2
array([[0, 1, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 1, 1, 1, 1, 0],
[3, 1, 1, 0, 0, 0, 0, 0]])
>>> pairs2
['A..A', 'A..L', 'A..Y', 'E..K', 'E..P', 'K..L', 'R..G', 'R..Y']
ctd¶
protlearn.features.ctd(X, *, start=1, end=None)
Conjoint triad descriptors.
These descriptors were initially developed to model protein-protein interactions. Amino acids can be grouped into 7 different classes based on their dipoles and side chain volumes, which reflect their electrostatic and hydrophobic interactions.
1 Dipole Scale (Debye): −, Dipole < 1.0; +, 1.0 < Dipole < 2.0; ++,
2.0 < Dipole < 3.0; +++, Dipole > 3.0; +′+′+′, Dipole > 3.0 with opposite orientation.
2 Volume Scale (A∘3): −, Volume < 50; +, Volume > 50.
3 Cys is separated from class 3 because of its ability to form disulfide bonds.
After grouping, these class triads are computed and normalized as follows:
where i corresponds to the CTD group and fi is the frequency of group i in the sequence.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 343)
Array containing conjoint triad descriptors.
- ctd_list: list of length 343
Unique class triads corresponding to columns in arr.
Notes¶
Columns containing only zeros will be deleted. Therefore, the returned array and list may have a lower dimensionality than 343, depending on the unique number conjoint triad descriptors in the dataset.
References¶
Shen J, Zhang J, Luo X, Zhu W, Yu K, Chen K, Li Y, Jiang H (2007) Predicting protein-protein interactions based only on sequences information. Proc Natl Acad Sci USA 104: 4337 – 4341
Examples¶
>>> from protlearn.features import ctd
>>> seqs = ['ARKKLYLYL', 'EEEERKPGL']
>>> ctd_arr, ctd_desc = ctd(seqs)
>>> ctd_arr
array([[1., 2., 1., 1., 1., 1., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 1., 0., 1., 1., 1., 1., 2.]])
>>> ctd_desc
['155', '232', '323', '523', '552', '555', '212', '521', '655', '665', '666']
ctdc¶
protlearn.features.ctdc(X, *, start=1, end=None)
Composition/Transition/Distribution - Composition.
Amino acids are categorized into 3 groups based on their physicochemical properties. The properties used here include hydrophobicity, normalized van der Waals volume, polarity, polarizability, charge, secondary structure, and solvent accessibility. For hydrophobicity, we use seven different groupings based on different studies, which can all be found in AAIndex1.
After grouping, the frequency of each class will be calculated for each physicochemical property per sequence in the dataset as follows:
where ni denotes the frequency of group i in the sequence, and N is the total sequence length.
For instance, the sequence ‘ARKLY’ translates to ‘23311’ with respect to polarity groups. Thus, for polarity, the outcome will be P1 = 2/5, P2 = 1/5, and P3 = 2/5.
As there are 13 different properties and 3 groups for each, the total dimension of this descriptor is 39.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 39)
Array containing grouped composition of physicochemical properties.
- desc: list of length 39
Descriptor properties corresponding to columns in arr.
References¶
Dubchak, I., Muchnik, I., Holbrook, S. R. & Kim, S.-H. Prediction of protein folding class using global description of amino acid sequence. Proceedings of the National Academy of Sciences 92, 8700–8704 (1995).
Dubchak, I., Muchnik, I., Mayor, C., Dralyuk, I. & Kim, S.-H. Recognition of a protein fold in the context of the scop classification. Proteins: Structure, Function, and Bioinformatics 35, 401–407 (1999).
Examples¶
>>> from protlearn.features import ctdc
>>> seqs = ['ARKLY', 'EERKPGL']
>>> c, desc = ctdc(seqs)
>>> c
array([[0. , 0.6 , 0.4 , 0.4 , 0.6 ,
0. , 0.6 , 0.2 , 0.2 , 0.4 ,
0. , 0.6 , 0.2 , 0.4 , 0.4 ,
0.4 , 0.4 , 0.2 , 0.4 , 0.2 ,
0.4 , 0.2 , 0.2 , 0.6 , 0.4 ,
0.2 , 0.4 , 0.2 , 0.2 , 0.6 ,
0.4 , 0.6 , 0. , 0.8 , 0.2 ,
0. , 0.4 , 0.4 , 0.2 ],
[0.42857143, 0.28571429, 0.28571429, 0.85714286, 0.14285714,
0. , 0.71428571, 0.14285714, 0.14285714, 0.57142857,
0.28571429, 0.14285714, 0.57142857, 0.28571429, 0.14285714,
0.57142857, 0.28571429, 0.14285714, 0.57142857, 0.14285714,
0.28571429, 0.28571429, 0.42857143, 0.28571429, 0.14285714,
0.28571429, 0.57142857, 0.14285714, 0.57142857, 0.28571429,
0.28571429, 0.42857143, 0.28571429, 0.71428571, 0. ,
0.28571429, 0.28571429, 0.57142857, 0.14285714]])
>>> desc
['Hydrophobicity_ARGP820101-G1',
'Hydrophobicity_ARGP820101-G2',
'Hydrophobicity_ARGP820101-G3',
'Hydrophobicity_CASG920101-G1',
'Hydrophobicity_CASG920101-G2',
'Hydrophobicity_CASG920101-G3',
'Hydrophobicity_ENGD860101-G1',
'Hydrophobicity_ENGD860101-G2',
'Hydrophobicity_ENGD860101-G3',
'Hydrophobicity_FASG890101-G1',
'Hydrophobicity_FASG890101-G2',
'Hydrophobicity_FASG890101-G3',
'Hydrophobicity_PONP930101-G1',
'Hydrophobicity_PONP930101-G2',
'Hydrophobicity_PONP930101-G3',
'Hydrophobicity_PRAM900101-G1',
'Hydrophobicity_PRAM900101-G2',
'Hydrophobicity_PRAM900101-G3',
'Hydrophobicity_ZIMJ680101-G1',
'Hydrophobicity_ZIMJ680101-G2',
'Hydrophobicity_ZIMJ680101-G3',
'Normalized van der Waals Volume-G1',
'Normalized van der Waals Volume-G2',
'Normalized van der Waals Volume-G3',
'Polarity-G1',
'Polarity-G2',
'Polarity-G3',
'Polarizability-G1',
'Polarizability-G2',
'Polarizability-G3',
'Charge-G1',
'Charge-G2',
'Charge-G3',
'Secondary structure-G1',
'Secondary structure-G2',
'Secondary structure-G3',
'Solvent accessibility-G1',
'Solvent accessibility-G2',
'Solvent accessibility-G3']
ctdt¶
protlearn.features.ctdt(X, *, start=1, end=None)
Composition/Transition/Distribution - Transition
Amino acids are categorized into 3 groups based on their physicochemical properties. The properties used here include hydrophobicity, normalized van der Waals volume, polarity, polarizability, charge, secondary structure, and solvent accessibility. For hydrophobicity, we use seven different groupings based on different studies, which can all be found in AAIndex1.
This descriptor computes the frequency of transitions between groups as follows:
where nij and nji denote the frequency of transitions from group i to j and j to i, respectively, in the sequence, and N is the total sequence length.
For instance, if the encoded sequence is ‘32132223311311222222’, then there are 2 transitions from groups 1 to 2 and 2 to 1. Therefore, the descriptor for this particular group transition will be 2/19. Similarly, there are 3 transitions from groups 2 to 3 and 3 to 2, so the descriptor for this transition is 3/19.
As with CTDC, the dimensionality of this feature is 39.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 39)
Array containing group transitions of physicochemical properties.
- desc: list of length 39
Order of transition groups corresponding to columns in arr.
References¶
Dubchak, I., Muchnik, I., Holbrook, S. R. & Kim, S.-H. Prediction of protein folding class using global description of amino acid sequence. Proceedings of the National Academy of Sciences 92, 8700–8704 (1995).
Dubchak, I., Muchnik, I., Mayor, C., Dralyuk, I. & Kim, S.-H. Recognition of a protein fold in the context of the scop classification. Proteins: Structure, Function, and Bioinformatics 35, 401–407 (1999).
Examples¶
>>> from protlearn.features import ctdt
>>> seqs = ['ARKLY', 'EERKPGL']
>>> t, desc = ctdt(seqs)
>>> t
array([[0. , 0. , 0.25 , 0.5 , 0. ,
0. , 0.25 , 0.5 , 0. , 0. ,
0.5 , 0. , 0.25 , 0.25 , 0. ,
0.25 , 0.25 , 0.25 , 0.25 , 0. ,
0.25 , 0. , 0.25 , 0.5 , 0. ,
0.25 , 0.25 , 0. , 0.25 , 0.5 ,
0.5 , 0. , 0. , 0.25 , 0. ,
0. , 0.5 , 0.25 , 0. ],
[0.16666667, 0.33333333, 0.16666667, 0.16666667, 0. ,
0. , 0.16666667, 0. , 0.16666667, 0.16666667,
0. , 0.16666667, 0.5 , 0. , 0.16666667,
0.16666667, 0. , 0.16666667, 0.16666667, 0.33333333,
0.16666667, 0.16666667, 0.16666667, 0.16666667, 0.16666667,
0. , 0.16666667, 0.33333333, 0. , 0.33333333,
0.16666667, 0.16666667, 0. , 0. , 0.33333333,
0. , 0. , 0.16666667, 0.16666667]])
>>> desc
['Hydrophobicity_ARGP820101-T1221',
'Hydrophobicity_ARGP820101-T1331',
'Hydrophobicity_ARGP820101-T2332',
'Hydrophobicity_CASG920101-T1221',
'Hydrophobicity_CASG920101-T1331',
'Hydrophobicity_CASG920101-T2332',
'Hydrophobicity_ENGD860101-T1221',
'Hydrophobicity_ENGD860101-T1331',
'Hydrophobicity_ENGD860101-T2332',
'Hydrophobicity_FASG890101-T1221',
'Hydrophobicity_FASG890101-T1331',
'Hydrophobicity_FASG890101-T2332',
'Hydrophobicity_PONP930101-T1221',
'Hydrophobicity_PONP930101-T1331',
'Hydrophobicity_PONP930101-T2332',
'Hydrophobicity_PRAM900101-T1221',
'Hydrophobicity_PRAM900101-T1331',
'Hydrophobicity_PRAM900101-T2332',
'Hydrophobicity_ZIMJ680101-T1221',
'Hydrophobicity_ZIMJ680101-T1331',
'Hydrophobicity_ZIMJ680101-T2332',
'Normalized van der Waals Volume-T1221',
'Normalized van der Waals Volume-T1331',
'Normalized van der Waals Volume-T2332',
'Polarity-T1221',
'Polarity-T1331',
'Polarity-T2332',
'Polarizability-T1221',
'Polarizability-T1331',
'Polarizability-T2332',
'Charge-T1221',
'Charge-T1331',
'Charge-T2332',
'Secondary structure-T1221',
'Secondary structure-T1331',
'Secondary structure-T2332',
'Solvent accessibility-T1221',
'Solvent accessibility-T1331',
'Solvent accessibility-T2332']
ctdd¶
protlearn.features.ctdd(X, *, start=1, end=None)
Composition/Transition/Distribution - Distribution
Amino acids are categorized into 3 groups based on their physicochemical properties. The properties used here include hydrophobicity, normalized van der Waals volume, polarity, polarizability, charge, secondary structure, and solvent accessibility. For hydrophobicity, we use seven different groupings based on different studies, which can all be found in AAIndex1.
There are five distribution descriptors for each physicochemical property and they are the position percents in the whole sequence for the first residue, 25% residues, 50% residues, 75% residues, and 100% residues for a certain encoded class. For instance, if the encoded sequence is ‘32132223311311222222’, then there are 10 residues encoded as 2. The positions for the first residue 2, the 2nd residue 2 (25% * 10 = 2), the 5th 2 residue (50% * 10 = 5), the 7th 2 (75% * 10 = 7) and the 10th residue 2 (100% * 10) in the encoded sequence are 2, 5, 15, 17, 20, so that the distribution descriptors for 2 are: 10.0 (2/20 * 100), 25.0 (5/20 * 100), 75.0 (15/20 * 100), 85.0 (17/20 * 100), 100.0 (20/20 * 100).
Since there are 13 physicochemical properties, 3 groups (see ctdc), and 5 distribution descriptors, the total dimensionality of this feature is 195.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 195)
Array containing grouped distribution of physicochemical properties.
- desc: list of length 195
Order of distribution groups corresponding to columns in arr.
References¶
Dubchak, I., Muchnik, I., Holbrook, S. R. & Kim, S.-H. Prediction of protein folding class using global description of amino acid sequence. Proceedings of the National Academy of Sciences 92, 8700–8704 (1995).
Dubchak, I., Muchnik, I., Mayor, C., Dralyuk, I. & Kim, S.-H. Recognition of a protein fold in the context of the scop classification. Proteins: Structure, Function, and Bioinformatics 35, 401–407 (1999).
Examples¶
>>> from protlearn.features import ctdc
>>> seqs = ['ARKLY', 'EERKPGL']
>>> d, desc = ctdd(seqs)
>>> d.shape
(2, 195)
>>> len(desc)
195
moreau_broto¶
protlearn.features.moreau_broto(X, *, d=1, properties=default, start=1, end=None)
Normalized Moreau-Broto autocorrelation based on AAIndex1.
Moreau-Broto autocorrelation descriptors are defined based on the distribution of AAIndex1-based amino acid properties along the sequence. All indices are standardized before computing the descriptors:
where Pi is the physicochemical property of the amino acid i, \(\overline{P}\) denotes the mean of the property of the 20 amino acids, and \(\sigma\) denotes the standard deviation.
Then, the Moreau_Broto descriptors are computed as follows:
where d denotes the lag of the autocorrelation, Pi and Pi+d are the properties of the amino acids at positions i and i+d, respectively, and nlag is the maximum value of the lag.
Finally, these descriptors are normalized:
where N denotes the total sequence length.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- properties: list
List of strings denoting AAIndex1 indices.
- d: int, default=1
Represents the lag. Must be smaller than sequence length. Maximum: 30.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, n_properties)
Array containing Moreau-Broto autocorrelation descriptors.
References¶
Moreau & Broto (1980), Autocorrelation of a topological structure: A new molecular descriptor, Nouv. J. Chim. 4, 359–360.
Feng, ZP., Zhang, CT. (2000): Prediction of membrane protein types based on the hydrophobic index of amino acids. J Protein Chem, 19: 262–275. 10.1023/A:1007091128394
Lin, Z., Pan, XM. (2001): Accurate prediction of protein secondary structural content. J Protein Chem, 20: 217–220. 10.1023/A:1010967008838
Xiao et al. (2015). protr/ProtrWeb: R package and web server for generating various numerical representation schemes of protein sequences. Bioinformatics 31 (11), 1857-1859
Examples¶
>>> from protlearn.features import moreau_broto
>>> seqs = ['ARKLY', 'EERKPGL']
>>> mb = moreau_broto(seqs)
>>> mb
array([[ 0.20075105, -0.19610635, -0.22859247, 0.40627137, -0.19552707,
0.16803808, 0.11262517, 0.3817956 ],
[ 0.34693551, 0.55361789, 0.12660283, 0.37790326, 0.43905717,
0.00559139, -0.09331898, 0.36367721]])
moran¶
protlearn.features.moran(X, *, d=1, properties=default, start=1, end=None)
Moran’s I based on AAIndex1.
Moran’s I autocorrelation descriptors are defined based on the distribution of AAIndex1-based amino acid properties along the sequence. All indices are standardized before computing the descriptors.
Moran’s I descriptors are computed as follows:
where N, d, Pi , and Pi+d are the same as in the Moreau-Broto autocorrelation. \(\overline{P}'\) is the considered property P along the sequence, which is defined as follows:
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- properties: list
List of strings denoting AAIndex1 indices.
- d: int, default=1
Represents the lag. Must be smaller than sequence length. Maximum: 30.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, n_properties)
Array containing Moran’s I autocorrelation descriptors.
References¶
Moran, P. (1950). Notes on Continuous Stochastic Phenomena. Biometrika, 37(1/2), 17-23. doi:10.2307/2332142
Horne, DS. (1988): Prediction of protein helix content from an autocorrelation analysis of sequence hydrophobicities. Biopolymers 27, 451–477
Li et al. (2007). Beyond Moran’s I: testing for spatial dependence based on the spatial autoregressive model. Geogr. Anal. 39, 357–375.
Xiao et al. (2015). protr/ProtrWeb: R package and web server for generating various numerical representation schemes of protein sequences. Bioinformatics 31 (11), 1857-1859
Examples¶
>>> from protlearn.features import moran
>>> seqs = ['ARKLY', 'EERKPGL']
>>> moranI = moran(seqs)
>>> moranI
array([[ 0.40090094, -0.31240708, -0.44083728, 0.26720303, -0.45198768,
-0.14684112, -0.05212843, 0.33703981],
[-0.0588976 , -0.36033526, 0.13170834, 0.18317369, 0.3884609 ,
-0.00724234, -0.19231646, 0.61711506]])
geary¶
protlearn.features.geary(X, *, d=1, properties=default, start=1, end=None)
Geary’s C based on AAIndex1.
Geary’s C autocorrelation descriptors are defined based on the distribution of AAIndex1-based amino acid properties along the sequence. All indices are standardized before computing the descriptors.
Geary’s C descriptors are computed as follows:
where N, d, Pi , and Pi+d are the same as in the Moreau-Broto autocorrelation, and \(\overline{P}'\) is the same as in Moran’s I.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- properties: list
List of strings denoting AAIndex1 indices.
- d: int, default=1
Represents the lag. Must be smaller than sequence length. Maximum: 30.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, n_properties)
Array containing Geary’s C autocorrelation descriptors.
References¶
Geary, R. (1954). The Contiguity Ratio and Statistical Mapping. The Incorporated Statistician, 5(3), 115-146. doi:10.2307/2986645
Jeffers, J. (1973). A Basic Subroutine for Geary’s Contiguity Ratio. Journal of the Royal Statistical Society. Series D (The Statistician), 22(4), 299-302. doi:10.2307/2986827
Sokal, RR., Thomson, BA. (2006). Population structure inferred by local spatial autocorrelation: an example from an Amerindian tribal population. Am J Phys Anthropol, 129: 121–131. 10.1002/ajpa.20250
Xiao et al. (2015). protr/ProtrWeb: R package and web server for generating various numerical representation schemes of protein sequences. Bioinformatics 31 (11), 1857-1859.
Examples¶
>>> from protlearn.features import geary
>>> seqs = ['ARKLY', 'EERKPGL']
>>> gearyC = geary(seqs)
>>> gearyC
array([[0.52746275, 1.12898944, 0.94222955, 0.39077186, 0.96444569,
0.66346012, 0.87481962, 0.32546227],
[0.65656058, 0.95397893, 0.87962853, 0.70972353, 0.65407555,
0.96823847, 1.01949384, 0.21073089]])
paac¶
protlearn.features.paac(X, *, lambda_=30, w=.05, start=1, end=None)
Pseudo amino acid composition.
Similar to the vanilla amino acid composition, this feature characterizes the protein mainly using a matrix of amino-acid frequencies, which helps with dealing with proteins without significant sequence homology to other proteins. However, additional information are also included in the matrix to represent some local features, such as correlation between residues of a certain distance.
First, the original hydrophobicity, hydrophilicity, and side chain mass values are converted using the following equation:
where P(i) denotes the converted property (hydrophobicity, hydrophilicity, or side chain mass) of amino acid i, and Po(i) denotes the original value of these properties.
Next, a correlation function is defined that averages the values of the three physicochemical properties:
where H1 , H2 , and M refer to hydrophilicity, hydrophilicity, and side chain mass, respectively, and Jk and Jl denote the amino acids at positions k and l.
Then, a set of sequence-order-correlated factors are defined as follows:
where \(\lambda\) is an integer parameter to be chosen and must be smaller than the sequence length N.
With fi being the normalized occurrence frequency of amino acid i in the sequence, a set of 20+ \(\lambda\) descriptors, called the pseudo amino acid composition, can be defined as:
where w is the weighting factor for the sequence-order effect and is set to 0.05 as suggested by Chou et al. (2001).
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- lambda_: int, default=30
Counted rank (tier) of the correlation along an amino acid sequence.
This parameter has to be smaller than the shortest sequence in the dataset.- w: float, default=.05
Weighting factor for the sequence-order effect.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 20+lambda_)
Array containing pseudo amino acid composition.
- desc: list of length 20+lambda_
Order of amino acids and lambda values corresponding to columns in arr.
Notes¶
Columns containing only zeros will be deleted. Therefore, the returned array and list may have a lower dimensionality than 20+lambda_.
References¶
Tanford C. Contribution of hydrophobic interactions to the stability of the globular conformation of proteins. J Am Chem Soc. 1962;84:4240–4247.
Hopp TP, Woods KR. Prediction of protein antigenic determinants from amino acid sequences. Proc Natl Acad Sci U S A. 1981 Jun;78(6):3824-8. doi: 10.1073/pnas.78.6.3824. PMID: 6167991; PMCID: PMC319665.
Chou KC. Prediction of protein cellular attributes using pseudo‐amino acid composition. Proteins. 2001; 43: 246‐ 255.
Jain et al. TpPred: A Tool for Hierarchical Prediction of Transport Proteins Using Cluster of Neural Networks and Sequence Derived Features. International Journal for Computational Biology (IJCB), 2012;1:28-36.
Examples¶
>>> from protlearn.features import paac
>>> seqs = ['ARKLY', 'EERKPGL']
>>> paac_comp, desc = paac(seqs, lambda_=3)
>>> paac_comp
array([[0.62956037, 0. , 0. , 0.62956037, 0.62956037,
0. , 0.62956037, 0.62956037, 0.10830885, 0.16327632,
0.09885446],
[0. , 1.49423911, 0.74711955, 0.74711955, 0.74711955,
0.74711955, 0.74711955, 0. , 0.04009348, 0.08251201,
0.13027496]])
>>> desc
['A', 'E', 'G', 'K', 'L', 'P', 'R', 'Y', 'lambda1', 'lambda2', 'lambda3']
apaac¶
protlearn.features.apaac(X, *, lambda_=30, w=.05, start=1, end=None)
Amphiphilic pseudo amino acid composition.
This feature has the same form as the vanilla amino acid composition, but contains much more information that is related to the sequence order of a protein and the distribution of the hydrophobic and hydrophilic amino acids along its chain.
Using H1 (i) and H2 (i) as defined above in the pseudo amino acid composition function, the correlation functions for hydrophobicity and hydrophilicity can be computed as follows:
Next, sequence-order factors can be defined as:
Finally, a set of descriptors, called amphiphilic pseudo amino acid composition, is defined as follows:
where w is the weighting factor, which is set to 0.05.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- lambda_: int, default=30
Counted rank (tier) of the correlation along an amino acid sequence.
This parameter has to be smaller than the shortest sequence in the dataset.- w: float, default=.05
Weighting factor for the sequence-order effect.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr: ndarray of shape (n_samples, 20+2*lambda_)
Array containing amphiphilic pseudo amino acid composition.
- desc: list of length 20+2*lambda_
Order of amino acids and lambda values corresponding to columns in arr.
Notes¶
Columns containing only zeros will be deleted. Therefore, the returned array and list may have a lower dimensionality than 20+2*lambda_.
References¶
Tanford C. Contribution of hydrophobic interactions to the stability of the globular conformation of proteins. J Am Chem Soc. 1962;84:4240–4247.
Hopp TP, Woods KR. Prediction of protein antigenic determinants from amino acid sequences. Proc Natl Acad Sci U S A. 1981 Jun;78(6):3824-8. doi: 10.1073/pnas.78.6.3824. PMID: 6167991; PMCID: PMC319665.
Chou KC. Using amphiphilic pseudo amino acid composition to predict enzyme subfamily classes. Bioinformatics. 2005 Jan 1;21(1):10-9. doi: 10.1093/bioinformatics/bth466. Epub 2004 Aug 12. PMID: 15308540.
Jain et al. TpPred: A Tool for Hierarchical Prediction of Transport Proteins Using Cluster of Neural Networks and Sequence Derived Features. International Journal for Computational Biology (IJCB), 2012;1:28-36.
Examples¶
>>> from protlearn.features import apaac
>>> seqs = ['ARKLY', 'EERKPGL']
>>> apaac_comp, desc = apaac(seqs, lambda_=3)
>>> apaac_comp
array([[ 1.15705278e+00, 0.00000000e+00, 0.00000000e+00,
1.15705278e+00, 1.15705278e+00, 0.00000000e+00,
1.15705278e+00, 1.15705278e+00, 1.38909208e-02,
3.13346727e-02, -8.12700103e-02, -6.96352986e-02,
-1.82775274e-05, -5.13547885e-02],
[ 0.00000000e+00, 1.64484218e+00, 8.22421091e-01,
8.22421091e-01, 8.22421091e-01, 8.22421091e-01,
8.22421091e-01, 0.00000000e+00, 4.76440749e-02,
6.11246926e-02, 1.80650812e-02, 5.07150233e-02,
-1.93053341e-02, 1.93353709e-02]])
>>> desc
['A',
'E',
'G',
'K',
'L',
'P',
'R',
'Y',
'lambda_hphob1',
'lambda_hphil1',
'lambda_hphob2',
'lambda_hphil2',
'lambda_hphob3',
'lambda_hphil3']
socn¶
protlearn.features.socn(X, *, d=30, start=1, end=None)
Sequence-order-coupling number.
This feature is derived from the distance matrix between the 20 amino acids. Here, we use two different distance matrices based on studies by Grantham and Schneider-Wrede, respectively.
The d-th rank sequence-order-coupling number is defined as follows:
where di,i+d is the value in a given distance matrix describing the distance between two amino acids at position i and i+d, nlag refers to the maximum value of the lag (30), and N is the total sequence length.
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- d: int, default=30
Represents the lag. Must be smaller than sequence length.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr_sw: ndarray of shape (n_samples, d)
Array containing SOCN based on the Schneider-Wrede distance matrix.
- arr_g: ndarray of shape (n_samples, d)
Array containing SOCN based on the Grantham distance matrix.
References¶
Grantham, R. (1974). Amino acid difference formula to help explain protein evolution. Science. 185 (4154): 862–864
Schneider & Wrede (1994). The Rational Design of Amino Acid Sequences by Artifical Neural Networks and Simulated Molecular Evolution: De Novo Design of an Idealized Leader Cleavge Site. Biophys Journal, 66, 335-344
Chou,K.-C. (2000) Prediction of protein subcellar locations by incorporating quasi-sequence-order effect. Biochemical and Biophysical Research Communications, 278, 477–483
Examples¶
>>> from protlearn.features import socn
>>> seqs = ['ARKLY', 'EERKPGL']
>>> sw, g = socn(seqs, d=3)
>>> sw
array([1.138343, 1.64627 , 2.150641])
>>> g
array([35009., 42394., 38859.])
qso¶
protlearn.features.qso(X, *, d=30, start=1, end=None)
Quasi-sequence-order.
This feature is derived from the distance matrix between the 20 amino acids. Here, we use two different distance matrices based on studies by Grantham and Schneider-Wrede, respectively.
For each amino acid i, a quasi-sequence-order descriptor can be computed as follows:
where fi is the normalized occurrence of amino acid type i and w is a weighting factor, which is set to 0.1. nlag and \(\tau_d\) are defined as in the sequence-order-coupling number function above.
The other 30 QSO descriptors are defined as follows:
Parameters¶
- X: string, fasta, or a list thereof
Dataset of amino acid sequences.
- d: int, default=30
Represents the lag. Must be smaller than sequence length.
- w: float, default=.1
Weighting factor for the sequence-order effect.
- start: int, default=1
Determines the starting point of the amino acid sequence. This number is based on one-based indexing.
- end: int, default=None
Determines the end point of the amino acid sequence. Similarly to start, this number is based on one-based indexing.
Returns¶
- arr_sw: ndarray of shape (n_samples, 20+d)
Array containing QSO based on the Schneider-Wrede distance matrix.
- arr_g: ndarray of shape (n_samples, 20+d)
Array containing QSO based on the Grantham distance matrix.
- desc: list of length 20+d
Order of QSO descriptors corresponding to columns in arr_sw and arr_g.
Notes¶
Columns containing only zeros will be deleted. Therefore, the returned arrays and list may have a lower dimensionality than 20+d.
References¶
Grantham, R. (1974). Amino acid difference formula to help explain protein evolution. Science. 185 (4154): 862–864
Schneider & Wrede (1994). The Rational Design of Amino Acid Sequences by Artifical Neural Networks and Simulated Molecular Evolution: De Novo Design of an Idealized Leader Cleavge Site. Biophys Journal, 66, 335-344
Chou,K.-C. (2000) Prediction of protein subcellar locations by incorporating quasi-sequence-order effect. Biochemical and Biophysical Research Communications, 278, 477–483
Examples¶
>>> from protlearn.features import qso
>>> seqs = ['ARKLY', 'EERKPGL']
>>> sw, g, desc = qso(seqs, d=3)
>>> sw
array([[0.66139001, 0. , 0. , 0.66139001, 0.66139001,
0. , 0.66139001, 0.66139001, 0.12285782, 0.15604737,
0.0597048 ],
[0. , 1.33911348, 0.66955674, 0.66955674, 0.66955674,
0.66955674, 0.66955674, 0. , 0.07621852, 0.11022712,
0.14399762]])
>>> g
array([[1.42887762e-04, 0.00000000e+00, 0.00000000e+00, 1.42887762e-04,
1.42887762e-04, 0.00000000e+00, 1.42887762e-04, 1.42887762e-04,
3.71008073e-01, 4.12445524e-01, 2.16403515e-01],
[0.00000000e+00, 1.72010458e-04, 8.60052291e-05, 8.60052291e-05,
8.60052291e-05, 8.60052291e-05, 8.60052291e-05, 0.00000000e+00,
3.01095707e-01, 3.64610568e-01, 3.34207720e-01]])
>>> desc
['A', 'E', 'G', 'K', 'L', 'P', 'R', 'Y', 'd1', 'd2', 'd3']


Welcome to Pat’s Salmon Cookies!
Sales Details
Seattle
- Location:12505 Bel-Red Rd #106, Bellevue, WA 98005، USA
- Working Hours: From 6:00 am to 8:00 pm
- contact info<EMAIL_ADDRESS>Tokyo
- Location:1-1 Chiyoda, Chiyoda City, Tokyo 100-8111، Japan
- Working Hours: From 6:00 am to 8:00 pm
- contact info<EMAIL_ADDRESS>Dubai
- Location:DownTown Jabal Ali
- Working Hours: From 6:00 am to 8:00 pm
- contact info<EMAIL_ADDRESS>Paris
- Location:Rue de Rivoli, 75001 Paris,France
- Working Hours: From 6:00 am to 8:00 pm
- contact info<EMAIL_ADDRESS>Lima
- Location:San Rafael SJL Gobierno Regional de Lima, LIMA 36
- Working Hours: From 6:00 am to 8:00 pm
- contact info: lima@yahoo.com


Each snapshot has to have a unique name. You can enter the name of the index yourself, or you can enter a prefix will will append a timestamp to the prefix in that case. If you provide a name as well as a prefix, we will use the name.


This responsive design guidebook for marketers provides an overview of the benefits, costs, risks, and opportunities of responsive web design. From determining whether a responsive design is what’s needed, to capturing the ROI of your responsive design project, we walk you through the key decision points and considerations when you’re contemplating a responsive design initiative.


--- title: Images subtitle: How to display images correctly in your slides using flexCarousel.js layout: example ---
flexCarousel.js also supports the HTML5 picture tag to give you more flexibility with responsive images.
picture


Chapter 1 Section 1
A Brief Introduction to Neurons
This first section is deceptively math-free and covers some basics about neurons. We’ll need to know these basics if we’re to understand the onslaught to come!
Neurons are cells that generate and propagate electrical impulses in response to stimuli. Impulses enter the neuron through its dendrites, travel along its axon, and trigger the release of neurotransmitter chemicals at its synaptic terminals. Dendrites are long, slender branching structures which extend from the soma, which is the center of the neuron and contains its nucleus. The axon is a thicker long structure which terminates in shorter branches.
Different types of neurons possess dendritic trees of different sizes, from thousands to hundreds of thousands of inputs (which each branch is an input). Axons connect to hundreds or thousands of other neurons and can range in size from a few millimeters to the length of the human body.
Ion channels - think of them as tunnels through which charged particles can move in response to certain environmental forces - dot the neuron membrane. Calcium (Ca2+), chloride (Cl-), potassium (K+), and sodium (Na+) ions play a prominent role. The differences between their concentrations inside and outside the neuron create an electrical potential (voltage) accross the neuron membrane. Changes in their concentration and in that potential activate ion channels and allow them to cross the membrane, further changing their concentration gradient and the electrical potential.
At “rest”, the voltage accross the membrane from outside to inside is -70mV. The inside of the neuron is polarized relative to its surroundings. When negatively charged ions flow into the cell or when positively charged ions flow out, the voltage drops further (hyperpolarization). When negative ions flow out of the cell or when positive ions flow in, the volage increases (depolarization). If we depolarize the neuron to the point that its inside is at a voltage of 100mV compared to its surroudings, this triggers an action potential, which is actively propagated down the axon to the synaptic terminals.
Once an action potential has occured (the neuron has “fired”), the neuron will enter a refractory period of tens of milliseconds during which it cannot fire. As action potentials reach the synaptic terminals they trigger the release of neurotransmitters into a space between the axon of this neuron and the dendritic branch of another. That space is known as the synapse. Neurotransmitters can either excite the next neuron or inhibit it via depolarization or hyperpolarization.
If we want to understand how neurons react to stimuli, we have to measure these electrical impulses. Measurements can be taken outside the neuron (extracellular) or inside it (intracellular). Intracellular measurements involve placing a very thin hollow glass electrode filled with a conducting electrolyte into the neuron. Its recorded electrical potential is compared to that of a reference electrode placed nearby. Extracellular measurements capture weaker signals as they are taken farther from the neuron where the electrical pulse is weaker. Measurements are usually made at the soma and measurements from axons and dendrites are harder to come by. Intracellular recordings are typically done in-vitro (think petri dishes) whereas extracelluar recordings are taken in-vivo (inside of a living creature). This isn’t always the case, just usually.
Even though we can measure action potentials (“spikes”), it’s difficult to understand how they relate to a specific stimulus. Neurons react to their own internal processes, those processes have a certain randomness associated with them, and experimental subjects are under various states of arousal and undergoing numerous cognitive processes. We can’t predict exactly what kind of response a stimulus will create and we will always measure a different set of spikes (or “spike train”) across different trials. So we instead try to predict the probability that a spike occurs within a given time interval. Much more on that later.
And that’s the intro! Don’t worry, much math to come. In the next section we’ll talk about how we measure firing rates, characterize the neuronal response, and predict average firing rates given a specific stimulus.


Daimler to cut thousands of managers to pay for electric cars
by Alex DanielDaimler, the maker of Mercedes-Benz cars, will cut a tenth of all its manager-level workers across the globe, in a bid to slash €1.4bn worth of personnel costs.
The German manufacturer said this morning the cuts came as its profit would fall significantly over the next two years because of the shift to electric vehicles.
Read more: Chinese success propels Mercedes-Benz to record third-quarter sales
Chief executive Ola Kallenius said: “The expenditure needed to achieve the [EU’s] CO2 targets require comprehensive measures to increase efficiency in all areas of our company.”
Kallenius, who took over at the firm in May, added: “The industry is in transformation.”
“We have to do this.”
Daimler and its peers are scrambling to reduce their overall carbon emissions, ahead of strict EU rules which come in next year.
Failure to meet the requirements could result in billions of euros-worth of fines from the EU. Daimler has already warned on profit several times last year, and has spent more than €500m as it gets up to speed on electrification.
It also agreed to pay an €870m fine over claims that nearly 700,000 failed to meet emissions rules.
This morning, Kallenius said restructuring plans would include a limit on investment and research at Mercedes, as well as job cuts.
“This can get quite emotional, but there are no two ways about it,” he said.

Shares fell nearly five per cent this morning, before recovering to 2.9 per cent down, valued at about €52.


In Pictures: Fishy encounter and scenic views as parties launch final voter push
The PM visited a fish market while the SNP battle bus took a trip to the Highlands.
Boris Johnson watched haddock being sold and held a cod in his arms for the cameras as he launched his final election campaign push in a fish market in Grimsby.
Meanwhile, the SNP battle bus visited the Highlands and Labour’s John McDonnell gave a speech on the economy in London.


Lizzo to grace 'Saturday Night Live' with a performance this December
by Alison ForemanLizzo will make her Saturday Night Live debut just in time for Christmas.
On Wednesday, SNL announced its December line-up with the Queen of Bop appearing as the musical guest alongside host Eddie Murphy on Dec. 21. Jennifer Lopez and DaBaby are scheduled for Dec. 7, while Scarlett Johansson and Niall Horan will appear Dec. 14.
The news comes hours after the 2020 Grammy nominations. Lizzo received the most nods of any artist this year with eight nominations — including album of the year (Cuz I Love You), song of the year ("Truth Hurts"), and best new artist.
Here's lookin' at you, Lizzo. Blame it on the Goose, blame it on the juice, etc.


#HOMEWORK2-TASK1-PART a
data = read.csv("C:/Users/negin/Desktop/Musk1.csv",sep=';',header = FALSE)
colnames(data) = c("Bag_class", "Bag_id", c(paste("Feature", 1:(ncol(data)-2), sep="")))
data
dim(data)
data1=data[,3:168]
#PCA
pca=princomp(data1, cor = TRUE, scores = TRUE)
plot(pca)
str(pca)
summary(pca)
#component1 covers 31.18% of the variance,component2 together covers 13.92% of the variance and so on, Which means that component1
#is really small and we can not use it to show the information. The data is not divided in to labeled classes in a good way.
pca.var= pca$sdev^2
pca.var = round(pca.var/sum(pca.var)*100,2)
par(mfrow=c(1,2))
plot(pca.var , xlab =" Principal Component ", ylab =" Proportion of Variance ")
plot(cumsum (pca.var), xlab =" Principal Component ", ylab ="Cumulative Proportion of Variance ")
data$color[data$Bag_class == 0] = "blue"
data$color[data$Bag_class == 1] = "red"
plot(pca$scores[,1], pca$scores[,2], col=data$color,
xlab = paste("PCA1 - ", pca.var.per[1], "%", sep=""),
ylab = paste("PCA2 - ", pca.var.per[2], "%", sep=""),
main = "PCA")
#MDS
dist_matrix = dist(scale(data1, center=TRUE, scale=TRUE), method="euclidean")
MDS=cmdscale(dist_matrix, eig=TRUE)
mds.var = round(MDS$eig/sum(MDS$eig)*100,2)
par(mfrow=c(1,2))
plot(mds.var, main = "Scree Plot", xlab = "MDS", ylab = "Percent of Variation")
plot(cumsum(mds.var), main = "Cumulative Scree Plot",
xlab = "MDS",ylab = "Cumulative Percent of Variance")
mds$values = mds$points
plot(mds$values[,1], mds$values[,2], col=data$color,
xlab = paste("MDS1 - ", mds.var[1], "%", sep=""),
ylab = paste("MDS2 - ", mds.var[2], "%", sep=""),
main = " MDS ")
#From the PCA and MDS two dimensional figures we can understand that the results for both methods are similar. if we
#use two components it will cover approximately 45% of the total variance. which is not very high value. It means that we have to
#use approximately 35 components to cover approximately 95 percent of the variance.
#TASK1-PART b
#Taking the average of the instance features
summerized_data=aggregate(data[,1:168],by=list(data$Bag_id), mean)
summerized_data
data2 = summerized_data[,3:168]
pr.out=prcomp(data2, scale=TRUE)
names (pr.out )
pr.out$sdev
pr.var =pr.out$sdev ^2
pve =pr.var /sum (pr.var )
pve
#As it can be seen from the average variances which is 26% for component1 and 18% for component2 and so on the which means that
#the things are getting worse. So this transformation approach is not good in Terms of PCA.
plot(pr.out)
pr.var = pr.out$sdev^2
pr.var = round(pr.var/sum(pr.var)*100,2)
par(mfrow=c(1,2))
plot(pr.var,xlab = "Principal Component", ylab = "Percent of Variation")
plot(cumsum(pr.var),xlab = "Principal Component",ylab = "Cumulative Percent of Variance Explained")
summerized_data$color[summerized_data$Bag_class == 0] = "blue"
summerized_data$color[summerized_data$Bag_class == 1] = "red"
plot(pr.out$x[,1], pr.out$x[,2], col=summerized_data$color,
xlab = paste("PCA1-", pr.var[1], "%", sep=""),
ylab = paste("PCA2-", pr.var[2], "%", sep=""),
main = "PCA-Averaged data")
#MDS
dist_matrix_1 = dist(scale(data2, center=TRUE, scale=TRUE), method="euclidean")
MDS_1=cmdscale(dist_matrix_1, eig=TRUE)
mds.var_1 = round(MDS_1$eig/sum(MDS_1$eig)*100,2)
par(mfrow=c(1,2))
plot(mds.var_1, main = "Scree Plot", xlab = "MDS", ylab = "Percent of Variation")
plot(cumsum(mds.var_1), main = "Cumulative Scree Plot",
xlab = "MDS",ylab = "Cumulative Percent of Variance")
MDS_1$values = MDS_1$points
plot(MDS_1$values[,1], MDS_1$values[,2], col=summerized_data$color,
xlab = paste("MDS1 - ", mds.var_1[1], "%", sep=""),
ylab = paste("MDS2 - ", mds.var_1[2], "%", sep=""),
main = " MDS-Averaged data ")
# By taking the average of the bag id the total coverage of first two components does not change,However,
# in the average case in order to cover 95% of the variance we have to use approximately 23 components which was 35 in the previous
#case which means that the dimension has decreased in the average scenario which is a good thing.
#Homework2-Task2-part(a)
install.packages("jpeg") ## if necessary
library(jpeg)
img=readJPEG("C:/Users/negin/Desktop/Task2.jpg")
str(img)
dim(img)
par(mfrow=c(1,1))
plot(0:256,0:256,type="n")
rasterImage(img,0,0, 256,256,interpolate=FALSE)
#Three channels
red=img[1:256,1:256,1]
green=img[1:256,1:256,2]
blue=img[1:256,1:256,3]
#Adding noise to image
red_noise=matrix(runif(256*256,min(red),0.1*max(red)),256,256)
green_noise=matrix(runif(256*256,min(green),0.1*max(green)),256,256)
blue_noise=matrix(runif(256*256,min(blue),0.1*max(blue)),256,256)
red=red+red_noise
green=green+green_noise
blue=blue+blue_noise
img[1:256,1:256,1]=red
img[1:256,1:256,2]=green
img[1:256,1:256,3]=blue
img=ifelse(img>1,1,img)
plot(0:256,0:256,type="n")
rasterImage(img,0,0,256,256,interpolate=FALSE)
#displaying each channel separately using image function
par(mfrow=c(1,3))
image(1:256,1:256,t(apply(red,2,rev)))
image(1:256,1:256,t(apply(green,2,rev)))
image(1:256,1:256,t(apply(blue,2,rev)))
img_red=img
img_red[,,2:3]=0
plot(0:256,0:256,type="n")
rasterImage(img_red,0,0,256,256,interpolate=FALSE)
img_green=img
img_green[,,c(1,3)]=0
plot(0:256,0:256,type="n")
rasterImage(img_green,0,0,256,256,interpolate=FALSE)
img_blue=img
img_blue[,,1:2]=0
plot(0:256,0:256,type="n")
rasterImage(img_blue,0,0,256,256,interpolate=FALSE)
#Transform noisy image to grayscale image
img_grayscale=img[,,1]+img[,,2]+img[,,3]
img_grayscale=img_grayscale/max(img_grayscale)
plot(c(0,1),c(0,1),t='n')
rasterImage(img_grayscale,0,0,1,1)
#data matrix
patches_matrix=matrix(0,53824,625)
i=1
for (n in 13:244){
for (k in 13:244){
patch1=img_grayscale[n-12,(k-12):(k+12)]
patch2=img_grayscale[n-11,(k-12):(k+12)]
patch3=img_grayscale[n-10,(k-12):(k+12)]
patch4=img_grayscale[n-9,(k-12):(k+12)]
patch5=img_grayscale[n-8,(k-12):(k+12)]
patch6=img_grayscale[n-7,(k-12):(k+12)]
patch7=img_grayscale[n-6,(k-12):(k+12)]
patch8=img_grayscale[n-5,(k-12):(k+12)]
patch9=img_grayscale[n-4,(k-12):(k+12)]
patch10=img_grayscale[n-3,(k-12):(k+12)]
patch11=img_grayscale[n-2,(k-12):(k+12)]
patch12=img_grayscale[n-1,(k-12):(k+12)]
patch13=img_grayscale[n,(k-12):(k+12)]
patch14=img_grayscale[n+1,(k-12):(k+12)]
patch15=img_grayscale[n+2,(k-12):(k+12)]
patch16=img_grayscale[n+3,(k-12):(k+12)]
patch17=img_grayscale[n+4,(k-12):(k+12)]
patch18=img_grayscale[n+5,(k-12):(k+12)]
patch19=img_grayscale[n+6,(k-12):(k+12)]
patch20=img_grayscale[n+7,(k-12):(k+12)]
patch21=img_grayscale[n+8,(k-12):(k+12)]
patch22=img_grayscale[n+9,(k-12):(k+12)]
patch23=img_grayscale[n+10,(k-12):(k+12)]
patch24=img_grayscale[n+11,(k-12):(k+12)]
patch25=img_grayscale[n+12,(k-12):(k+12)]
patches_matrix[i,]=c(patch1,patch2,patch3,patch4,patch5,patch6,patch7,patch8,patch9,patch10,patch11,patch12,patch13,patch14
,patch15,patch16,patch17,patch18,patch19,patch20,patch21,patch22,patch23,patch24,patch25)
i=i+1}}
#PCA
pca_image=princomp(patches_matrix, cor = TRUE, scores = TRUE)
plot(pca_image)
str(pca_image)
summary(pca_image)
#We can see that component1 covers 69% of the total variance and the component2 covers 6% of the total variance
#so on. We can use three components to create the matrix ,
comp1_img=matrix(0,232,232)
i=1
for (m in 1:232)
{comp1_img[m,]=pca_image$scores[i:(232*m),1]
i=232*m+1
}
comp2_img=matrix(0,232,232)
i=1
for (m in 1:232)
{comp2_img[m,]=pca_image$scores[i:(232*m),2]
i=232*m+1
}
comp3_img=matrix(0,232,232)
i=1
for (m in 1:232)
{comp3_img[m,]=pca_image$scores[i:(232*m),3]
i=232*m+1
}
#use component1 to reconstruct image
plot(c(0,1),c(0,1),t='n')
rasterImage((comp1_img-min(comp1_img))/(max(comp1_img)-min(comp1_img)),0,0,1,1)
#use component2 to reconstruct image
plot(c(0,1),c(0,1),t='n')
rasterImage((comp2_img-min(comp2_img))/(max(comp2_img)-min(comp2_img)),0,0,1,1)
#use component3 to reconstruct image
plot(c(0,1),c(0,1),t='n')
rasterImage((comp3_img-min(comp3_img))/(max(comp3_img)-min(comp3_img)),0,0,1,1)
#we can see from the reconstructed images that the component1 gives better reconstructed image than the others. But we can use
#three components together to reconstruct the image better.
#Covariance matrix
#Eigenvalues
#Eigenvectors
covariance_pca_image=cov(patches_matrix)
eigenvalues=eigen(covariance_pca_image)$values
eigenvectors=eigen(covariance_pca_image)$vectors
dim(eigenvectors)
#patches of eigenvectors
patch_eigenvector1=matrix(0,25,25)
patch_eigenvector2=matrix(0,25,25)
patch_eigenvector3=matrix(0,25,25)
patch_eigenvector4=matrix(0,25,25)
patch_eigenvector5=matrix(0,25,25)
patch_eigenvector6=matrix(0,25,25)
patch_eigenvector7=matrix(0,25,25)
patch_eigenvector8=matrix(0,25,25)
patch_eigenvector9=matrix(0,25,25)
patch_eigenvector10=matrix(0,25,25)
patch_eigenvector11=matrix(0,25,25)
patch_eigenvector12=matrix(0,25,25)
patch_eigenvector13=matrix(0,25,25)
patch_eigenvector14=matrix(0,25,25)
patch_eigenvector15=matrix(0,25,25)
patch_eigenvector16=matrix(0,25,25)
patch_eigenvector17=matrix(0,25,25)
patch_eigenvector18=matrix(0,25,25)
patch_eigenvector19=matrix(0,25,25)
patch_eigenvector20=matrix(0,25,25)
patch_eigenvector21=matrix(0,25,25)
patch_eigenvector22=matrix(0,25,25)
patch_eigenvector23=matrix(0,25,25)
patch_eigenvector24=matrix(0,25,25)
patch_eigenvector25=matrix(0,25,25)
patch_eigenvector1[1,]=eigenvectors[1:25,1]
patch_eigenvector1[2,]=eigenvectors[26:50,1]
patch_eigenvector1[3,]=eigenvectors[51:75,1]
patch_eigenvector1[4,]=eigenvectors[76:100,1]
patch_eigenvector1[5,]=eigenvectors[101:125,1]
patch_eigenvector1[6,]=eigenvectors[126:150,1]
patch_eigenvector1[7,]=eigenvectors[151:175,1]
patch_eigenvector1[8,]=eigenvectors[176:200,1]
patch_eigenvector1[9,]=eigenvectors[201:225,1]
patch_eigenvector1[10,]=eigenvectors[226:250,1]
patch_eigenvector1[11,]=eigenvectors[251:275,1]
patch_eigenvector1[12,]=eigenvectors[276:300,1]
patch_eigenvector1[13,]=eigenvectors[301:325,1]
patch_eigenvector1[14,]=eigenvectors[326:350,1]
patch_eigenvector1[15,]=eigenvectors[351:375,1]
patch_eigenvector1[16,]=eigenvectors[376:400,1]
patch_eigenvector1[17,]=eigenvectors[401:425,1]
patch_eigenvector1[18,]=eigenvectors[426:450,1]
patch_eigenvector1[19,]=eigenvectors[451:475,1]
patch_eigenvector1[20,]=eigenvectors[476:500,1]
patch_eigenvector1[21,]=eigenvectors[501:525,1]
patch_eigenvector1[22,]=eigenvectors[526:550,1]
patch_eigenvector1[23,]=eigenvectors[551:575,1]
patch_eigenvector1[24,]=eigenvectors[576:600,1]
patch_eigenvector1[25,]=eigenvectors[601:625,1]
patch_eigenvector2[1,]=eigenvectors[1:25,2]
patch_eigenvector2[2,]=eigenvectors[26:50,2]
patch_eigenvector2[3,]=eigenvectors[51:75,2]
patch_eigenvector2[4,]=eigenvectors[76:100,2]
patch_eigenvector2[5,]=eigenvectors[101:125,2]
patch_eigenvector2[6,]=eigenvectors[126:150,2]
patch_eigenvector2[7,]=eigenvectors[151:175,2]
patch_eigenvector2[8,]=eigenvectors[176:200,2]
patch_eigenvector2[9,]=eigenvectors[201:225,2]
patch_eigenvector2[10,]=eigenvectors[226:250,2]
patch_eigenvector2[11,]=eigenvectors[251:275,2]
patch_eigenvector2[12,]=eigenvectors[276:300,2]
patch_eigenvector2[13,]=eigenvectors[301:325,2]
patch_eigenvector2[14,]=eigenvectors[326:350,2]
patch_eigenvector2[15,]=eigenvectors[351:375,2]
patch_eigenvector2[16,]=eigenvectors[376:400,2]
patch_eigenvector2[17,]=eigenvectors[401:425,2]
patch_eigenvector2[18,]=eigenvectors[426:450,2]
patch_eigenvector2[19,]=eigenvectors[451:475,2]
patch_eigenvector2[20,]=eigenvectors[476:500,2]
patch_eigenvector2[21,]=eigenvectors[501:525,2]
patch_eigenvector2[22,]=eigenvectors[526:550,2]
patch_eigenvector2[23,]=eigenvectors[551:575,2]
patch_eigenvector2[24,]=eigenvectors[576:600,2]
patch_eigenvector2[25,]=eigenvectors[601:625,2]
patch_eigenvector3[1,]=eigenvectors[1:25,3]
patch_eigenvector3[2,]=eigenvectors[26:50,3]
patch_eigenvector3[3,]=eigenvectors[51:75,3]
patch_eigenvector3[4,]=eigenvectors[76:100,3]
patch_eigenvector3[5,]=eigenvectors[101:125,3]
patch_eigenvector3[6,]=eigenvectors[126:150,3]
patch_eigenvector3[7,]=eigenvectors[151:175,3]
patch_eigenvector3[8,]=eigenvectors[176:200,3]
patch_eigenvector3[9,]=eigenvectors[201:225,3]
patch_eigenvector3[10,]=eigenvectors[226:250,3]
patch_eigenvector3[11,]=eigenvectors[251:275,3]
patch_eigenvector3[12,]=eigenvectors[276:300,3]
patch_eigenvector3[13,]=eigenvectors[301:325,3]
patch_eigenvector3[14,]=eigenvectors[326:350,3]
patch_eigenvector3[15,]=eigenvectors[351:375,3]
patch_eigenvector3[16,]=eigenvectors[376:400,3]
patch_eigenvector3[17,]=eigenvectors[401:425,3]
patch_eigenvector3[18,]=eigenvectors[426:450,3]
patch_eigenvector3[19,]=eigenvectors[451:475,3]
patch_eigenvector3[20,]=eigenvectors[476:500,3]
patch_eigenvector3[21,]=eigenvectors[501:525,3]
patch_eigenvector3[22,]=eigenvectors[526:550,3]
patch_eigenvector3[23,]=eigenvectors[551:575,3]
patch_eigenvector3[24,]=eigenvectors[576:600,3]
patch_eigenvector3[25,]=eigenvectors[601:625,3]
#Plot of the first eigenvector
plot(c(0,1),c(0,1),t='n')
rasterImage((patch_eigenvector1-min(patch_eigenvector1))/(max(patch_eigenvector1)-min(patch_eigenvector1)),0,0,1,1,interpolate=FALSE)
#Plot of the second eigenvector
plot(c(0,1),c(0,1),t='n')
rasterImage((patch_eigenvector2-min(patch_eigenvector2))/(max(patch_eigenvector2)-min(patch_eigenvector2)),0,0,1,1,interpolate=FALSE)
#Plot of the third eigenvector
plot(c(0,1),c(0,1),t='n')
rasterImage((patch_eigenvector3-min(patch_eigenvector3))/(max(patch_eigenvector3)-min(patch_eigenvector3)),0,0,1,1,interpolate=FALSE)
#we see that first eigenvector displays mostly the center of the image.
#Second and third eigenvectors represent other parts of the image.


<glossarylist>
The <glossarylist>
element references a list of glossary entries within
the book. It indicates to the processing software that the author wants a glossary list
generated at the particular location.
Category: Bookmap content elements


Empty Link:
Ignored Link
Hash Link
Relative Path Link
Full Path Link
Test duplicate URLs: Full Path Link 2
Autolink: http://www.google.com/
Over-Styled Link