FIND A SPECIFIC ELEMENT WITHIN A LIST OF GENE SYMBOLS
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
darova
il 24 Apr 2020
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
Sa
il 25 Apr 2020
darova
il 25 Apr 2020
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
darova
il 25 Apr 2020
String delimiter might be 'space'

Can't be 'space' and 'tab' ath the same time. How your data separated?
Sa
il 25 Apr 2020
darova
il 25 Apr 2020
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
Sa
il 25 Apr 2020
darova
il 25 Apr 2020
Can you please attach the data?
Sa
il 26 Apr 2020
darova
il 26 Apr 2020
Try this
A = readtable('ShortMouseDatabase.xlsx');
gene = table2array(A(:,2));
n = strfind(gene,'Copg1');
ix = ~cellfun(@isempty,n);
A(ix,1)
Sa
il 26 Apr 2020
darova
il 26 Apr 2020
- 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
>> a = [0 0 1 1 0 0]
a =
0 0 1 1 0 0
>> ~a
ans =
1 1 0 0 1 1
Sa
il 26 Apr 2020
Walter Roberson
il 26 Apr 2020
A = readtable('data.txt','delimiter','\t');
A(contains(A{:,2}, 'Copg1'), 1)
darova
il 26 Apr 2020
n is cell array to which function is applied
darova
il 26 Apr 2020
What does it supposed to mean?
Sa
il 27 Apr 2020
Categorie
Scopri di più su Birthdays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!