Posts

Showing posts with the label ClustUtils

Presence Absence Matrix

Given a cluster file, one can create a Presence-Absence matrix (PA map). With this self-explanatory simple matlab file it is easy to create one. Input Format: Cluster file.xlsx: (1) A  B  C  D (2) A  A  A (3) B C (4) D D A List File.xlsx: A B C D Output : (of course, the output will have the file with only numbers printed)      A B C D (1) 1  1  1  1 (2) 1  0  0  0 (3) 0  1  1  0 (4) 1  0  0  1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 %Author = Arun Prasanna %Create a presence absence matrix (PA map) from cluster information clear ; clc ; [ mat1 , mat ] = xlsread ( 'ClusterFile.xlsx' , 'Sheet1' ); clear mat1 [ mat2 , head ] = xlsread ( 'List.xlsx' , 'Header' ); clear mat2 new_head = head (:, col_val ); %col_val = 2 => column that has unique sp/gene list [ rmat , cmat ] ...

Gene Copy Number Matrix

Given a cluster file, one can create a gene copy number matrix (GCN). With this self-explanatory simple matlab file it is easy to create one. Input Format: Cluster file.xlsx: (1) A  B  C  D (2) A  A  A (3) B C (4) D D A List File.xlsx: A B C D Output: (of course, the output will have the file with only numbers printed)      A B C D (1) 1  1  1  1 (2) 3  0  0  0 (3) 0  1  1  0 (4) 1  0  0  2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 %Author = Arun Prasanna %Create a gene copy number matrix from cluster information clear ; clc ; tic [ mat1 , mat ] = xlsread ( 'ClusterFile.xlsx' , 'Sheet1' ); clear mat1 [ mat2 , head ] = xlsread ( 'Organism_list.xlsx' , 'Sheet1' ); clear mat2 %species/gene name new_head = head (:, 1 ) ' ; %transpose to make it as header [ rmat , cm...

Hash_lookup for Cluster data

Hashes are exciting !! Hash tables are one of the most powerful lookup operations !. It gives the power of random access & hence lightning fast :-).  Imagine that, you have non-homogenous data (again: inconsistent number of column values, for instance cluster data). You have a list and you have to map the entries or fish the desired value from the huge file ! For example, your query file has 65000 entries and cluster file has 100000 entries in which the first column is the correspondence. If you just write the basic 'for loop' it is going to iterate atleast 65000 * 100000 (in case of thorough search) or slightly lesser if you break after a match is found. In any case, it can time humongous amount of time. Solution ? Hashes !! For same number of entries, my job took 3-7 seconds !  Dictionaries in python can also do the same thing !  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #Code to map clu...