mirror of
https://github.com/MillironX/beefblup.git
synced 2024-12-22 17:08:16 +00:00
Excluded null values from UNIQUE enumerations
This commit is contained in:
parent
6743790804
commit
f2a60fee49
3 changed files with 21 additions and 2 deletions
|
@ -44,7 +44,7 @@ end
|
||||||
|
|
||||||
% Find any columns that need to be deleted
|
% Find any columns that need to be deleted
|
||||||
for i = 7:length(headers)
|
for i = 7:length(headers)
|
||||||
if length(unique(data(:,i))) <= 1
|
if length(uniquecell(data(:,i))) <= 1
|
||||||
colname = headers{i};
|
colname = headers{i};
|
||||||
disp(['Column "' colname '" does not have any unique animals and will be removed from this analysis.']);
|
disp(['Column "' colname '" does not have any unique animals and will be removed from this analysis.']);
|
||||||
colstodelete = [colstodelete i];
|
colstodelete = [colstodelete i];
|
||||||
|
@ -58,7 +58,7 @@ headers(colstodelete) = [];
|
||||||
% Determine how many contemporary groups there are
|
% Determine how many contemporary groups there are
|
||||||
numgroups = ones(1, length(headers)-5);
|
numgroups = ones(1, length(headers)-5);
|
||||||
for i = 6:length(headers)
|
for i = 6:length(headers)
|
||||||
numgroups(i) = length(unique(data(:,i)));
|
numgroups(i-5) = length(uniquecell(data(:,i)));
|
||||||
end
|
end
|
||||||
|
|
||||||
% If there are more groups than animals, then the analysis cannot continue
|
% If there are more groups than animals, then the analysis cannot continue
|
||||||
|
|
9
MATLAB/uniquecell.m
Normal file
9
MATLAB/uniquecell.m
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
% uniquenan
|
||||||
|
% Serves the same purpose as UNIQUE, but ensures any empty cells are not
|
||||||
|
% counted
|
||||||
|
function y = uniquecell(x)
|
||||||
|
y = unique(x);
|
||||||
|
if any(cellfun(@isempty, y))
|
||||||
|
y(cellfun(@isempty, y)) = [];
|
||||||
|
end
|
||||||
|
end
|
10
MATLAB/uniquenan.m
Normal file
10
MATLAB/uniquenan.m
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
% uniquenan
|
||||||
|
% Serves the same purpose as UNIQUE, but ensures any NaN fields are not
|
||||||
|
% counted
|
||||||
|
function y = uniquenan(x)
|
||||||
|
y = unique(x);
|
||||||
|
if any(isnan(y))
|
||||||
|
y(isnan(y)) = [];
|
||||||
|
y(end + 1) = NaN;
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue