FIND A SPECIFIC ELEMENT WITHIN A LIST OF GENE SYMBOLS

Hello everybody,
Could anyone suggest to me which kind of function I can use to find a specifi element whithin a list of gene symbols? I tried to use find but I couldn't get what I needed. Probably, I didn't use this function in a proper way.
Thanks for your help

4 Commenti

PLease show sample data. Show the code you used. Show the result you want to expect
Be more specific
What about strfind?
Ok, Thanks a lot.
Can I write something like that:
index = find (contains(MOUSEMATLAB,'March5'))
in which MOUSEMATLAB is my list of gene symbols and March5 is the specific element that I'm looking for.
I tried to use it and I got this:
Did you mean:
>> index = find (contains(MOUSEMATLAB,'March5'));
I don't understand what it means.
Thanks

Accedi per commentare.

 Risposta accettata

Sa
Sa il 24 Apr 2020
Probe Set ID Gene Symbol
1415670_at Copg1
1415671_at Atp6v0d1
1415672_at Golga7
1415673_at Psph
1415674_a_at Trappc4
1415675_at Dpm2
This is part of the list that I have. For instance, I need to find a specific gene symbol such as Copg1 and its corresponding probeset ID whithin this list.
Thanks

2 Commenti

Please use comments section. Don't produce answer
ok, sorry!

Accedi per commentare.

Più risposte (1)

Try this
A = readtable('data.txt','delimiter','\t')
GENE = table2array(A(:,2)); % convert to cell
ix = strfind(GENE, 'Copg1'); % search in each cell
ix = cellfun(@isempty,ix); % find empty cells
A(~ix,1) % display ID

16 Commenti

Ok, thanks.
I tried it but I didn't get what I need.
Here's what I got
A =
6×1 table
ProbeSetIDGeneSymbol
_________________________
{'1415670_at Copg1' }
{'1415671_at Atp6v0d1'}
{'1415672_at Golga7' }
{'1415673_at Psph' }
{'1415674_a_at Trappc4' }
{'1415675_at Dpm2' }
Variable index exceeds table dimensions.
This please?
A = importdata('data.txt');
for i = 2:size(A,1)
A1(i-1,:) = strsplit(A{i},' ');
end
ix = strfind(A1(:,2), 'Copg1'); % search in each cell
ix = cellfun(@isempty,ix); % find empty cells
A1(~ix,:) % display ID
String delimiter might be 'space'
Can't be 'space' and 'tab' ath the same time. How your data separated?
Hi,
Thanks a lot for your help.
When I try this script using the file data.txt (the one that you sent to me), the script works and I can get the result I need. Instead, when I try it using my file MOUSE.txt it doesn't work. Here is the ans I get:
Unable to perform assignment because the size of the left side is 1-by-2 and the size of the right side is
1-by-7.
I am wondering if I can use another type of file rather than txt. For instance, a file excel that I can import in matlab.
Thanks
Another attempt
clc,clear
A = importdata('data.txt');
for i = 2:size(A,1)
a = textscan(A{i},'%s');
A1(i-1,:) = cat(2,a{:});
end
ix = strfind(A1(:,2), 'Copg1'); % search in each cell
ix = cellfun(@isempty,ix); % find empty cells
A1(~ix,:) % display ID
  • I am wondering if I can use another type of file rather than txt. For instance, a file excel that I can import in matlab.
Yes, you can. But don't think it changes something. You have 'tab' and 'space' as a separation symbols
Sorry but it doesn't work even this time. If I use the file MOUSE.txt, this is the ans I got:
Unable to perform assignment because the size of the left side is 1-by-2 and the size of the right side is
6-by-1. It is similar to the previous one. I don't understand what it means.
Instead, if I use a file .xlsx, I get this result:
ans =
0×2 empty cell array
Thanks a lot
Can you please attach the data?
Hello,
Here is the data.
Thanks
Try this
A = readtable('ShortMouseDatabase.xlsx');
gene = table2array(A(:,2));
n = strfind(gene,'Copg1');
ix = ~cellfun(@isempty,n);
A(ix,1)
It works and I can get the result, thanks a lot.
have you used table2array because to use strfind your data needs to be an arry?
What does (@isempty,n) mean? Why do you put ~ before cellfun?
  • have you used table2array because to use strfind your data needs to be an arry?
Exactly. strfind refused to take table
  • What does (@isempty,n) mean? Why do you put ~ before cellfun?
strfind returns cell arra. Cell can be empty or has some number. Number means position of substr in a cell. Empty cell means that substr was not found. I want to find all cells that are not empty. isempty check if cell is empty and return 0 or 1 (1 - empty). ix is logical array (0 and 1) of length gene
'~' tilde symbol means logical NOT
>> a = [0 0 1 1 0 0]
a =
0 0 1 1 0 0
>> ~a
ans =
1 1 0 0 1 1
Thanks, I understand it better now.
Is n referred to each cell of the array?
A = readtable('data.txt','delimiter','\t');
A(contains(A{:,2}, 'Copg1'), 1)
n is cell array to which function is applied
What does it supposed to mean?
OK, perfect. Really, thanks a lot

Accedi per commentare.

Categorie

Richiesto:

Sa
il 24 Apr 2020

Commentato:

Sa
il 27 Apr 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by