Delete rows where 5 or more columns have values less than 3
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a dataset of RNAseq from featureCounts which I have merged. I have 3 conditions with 3 replicates. I want to delete rows where 5 or more columns have values less than 3 of gene expression
Here is a sample of my dataset.
Gene_id. M1 M2 M3 W1 W2 W3 S1 S2 S3
ENSMUSG00000102693 18 4 5 8 0 2 1 0 0
ENSMUSG00000064842 1 0 0 0 0 0 1 1 2
ENSMUSG00000051951 25 23 32 54 78 77 48 56 33
ENSMUSG00000102851 0 0 0 0 0 0 0 0 0
ENSMUSG00000103377 0 10 0 2 5 0 6 7 8
I would like to import this dataset for further DE analysis in another tool for analysis.
text-processing bioinformatics
New contributor
add a comment |
up vote
0
down vote
favorite
I have a dataset of RNAseq from featureCounts which I have merged. I have 3 conditions with 3 replicates. I want to delete rows where 5 or more columns have values less than 3 of gene expression
Here is a sample of my dataset.
Gene_id. M1 M2 M3 W1 W2 W3 S1 S2 S3
ENSMUSG00000102693 18 4 5 8 0 2 1 0 0
ENSMUSG00000064842 1 0 0 0 0 0 1 1 2
ENSMUSG00000051951 25 23 32 54 78 77 48 56 33
ENSMUSG00000102851 0 0 0 0 0 0 0 0 0
ENSMUSG00000103377 0 10 0 2 5 0 6 7 8
I would like to import this dataset for further DE analysis in another tool for analysis.
text-processing bioinformatics
New contributor
Thank you for providing sample input. Now please add corresponding output.
– Scott
Nov 19 at 4:16
I am looking for commands to enable me create an output
– Sam
Nov 19 at 4:24
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a dataset of RNAseq from featureCounts which I have merged. I have 3 conditions with 3 replicates. I want to delete rows where 5 or more columns have values less than 3 of gene expression
Here is a sample of my dataset.
Gene_id. M1 M2 M3 W1 W2 W3 S1 S2 S3
ENSMUSG00000102693 18 4 5 8 0 2 1 0 0
ENSMUSG00000064842 1 0 0 0 0 0 1 1 2
ENSMUSG00000051951 25 23 32 54 78 77 48 56 33
ENSMUSG00000102851 0 0 0 0 0 0 0 0 0
ENSMUSG00000103377 0 10 0 2 5 0 6 7 8
I would like to import this dataset for further DE analysis in another tool for analysis.
text-processing bioinformatics
New contributor
I have a dataset of RNAseq from featureCounts which I have merged. I have 3 conditions with 3 replicates. I want to delete rows where 5 or more columns have values less than 3 of gene expression
Here is a sample of my dataset.
Gene_id. M1 M2 M3 W1 W2 W3 S1 S2 S3
ENSMUSG00000102693 18 4 5 8 0 2 1 0 0
ENSMUSG00000064842 1 0 0 0 0 0 1 1 2
ENSMUSG00000051951 25 23 32 54 78 77 48 56 33
ENSMUSG00000102851 0 0 0 0 0 0 0 0 0
ENSMUSG00000103377 0 10 0 2 5 0 6 7 8
I would like to import this dataset for further DE analysis in another tool for analysis.
text-processing bioinformatics
text-processing bioinformatics
New contributor
New contributor
edited Nov 19 at 4:14
Scott
6,59942650
6,59942650
New contributor
asked Nov 19 at 4:05
Sam
81
81
New contributor
New contributor
Thank you for providing sample input. Now please add corresponding output.
– Scott
Nov 19 at 4:16
I am looking for commands to enable me create an output
– Sam
Nov 19 at 4:24
add a comment |
Thank you for providing sample input. Now please add corresponding output.
– Scott
Nov 19 at 4:16
I am looking for commands to enable me create an output
– Sam
Nov 19 at 4:24
Thank you for providing sample input. Now please add corresponding output.
– Scott
Nov 19 at 4:16
Thank you for providing sample input. Now please add corresponding output.
– Scott
Nov 19 at 4:16
I am looking for commands to enable me create an output
– Sam
Nov 19 at 4:24
I am looking for commands to enable me create an output
– Sam
Nov 19 at 4:24
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
As I understand your question, you want
awk '
count=0
for (i=2; i<=NF; i++) if ($i < 3) count++
if (count < 5) print
'
For each line, set a counter to zero.
Then look at each field (column) other than the first (the Gene ID),
and, if it is less than 3, count it.
Then, if the count is less than five, print the line.
If five or more columns have values less than 3,
skip the line (i.e., delete it).
If you need to collapse this into a single line,
you must add semicolons (;
) after the statements
(i.e., where the line breaks are in the above version):
awk ' count=0; for (i=2; i<=NF; i++) if ($i < 3) count++; if (count < 5) print; '
this is the error message I get [lcoscoy@ln001 bin]$ awk 'count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print' RNA.txt awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error
– Sam
Nov 19 at 6:50
See edited answer.
– Scott
Nov 19 at 6:57
Hi Scott, thanks this worked perfectly
– Sam
Nov 19 at 7:15
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
As I understand your question, you want
awk '
count=0
for (i=2; i<=NF; i++) if ($i < 3) count++
if (count < 5) print
'
For each line, set a counter to zero.
Then look at each field (column) other than the first (the Gene ID),
and, if it is less than 3, count it.
Then, if the count is less than five, print the line.
If five or more columns have values less than 3,
skip the line (i.e., delete it).
If you need to collapse this into a single line,
you must add semicolons (;
) after the statements
(i.e., where the line breaks are in the above version):
awk ' count=0; for (i=2; i<=NF; i++) if ($i < 3) count++; if (count < 5) print; '
this is the error message I get [lcoscoy@ln001 bin]$ awk 'count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print' RNA.txt awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error
– Sam
Nov 19 at 6:50
See edited answer.
– Scott
Nov 19 at 6:57
Hi Scott, thanks this worked perfectly
– Sam
Nov 19 at 7:15
add a comment |
up vote
0
down vote
accepted
As I understand your question, you want
awk '
count=0
for (i=2; i<=NF; i++) if ($i < 3) count++
if (count < 5) print
'
For each line, set a counter to zero.
Then look at each field (column) other than the first (the Gene ID),
and, if it is less than 3, count it.
Then, if the count is less than five, print the line.
If five or more columns have values less than 3,
skip the line (i.e., delete it).
If you need to collapse this into a single line,
you must add semicolons (;
) after the statements
(i.e., where the line breaks are in the above version):
awk ' count=0; for (i=2; i<=NF; i++) if ($i < 3) count++; if (count < 5) print; '
this is the error message I get [lcoscoy@ln001 bin]$ awk 'count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print' RNA.txt awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error
– Sam
Nov 19 at 6:50
See edited answer.
– Scott
Nov 19 at 6:57
Hi Scott, thanks this worked perfectly
– Sam
Nov 19 at 7:15
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
As I understand your question, you want
awk '
count=0
for (i=2; i<=NF; i++) if ($i < 3) count++
if (count < 5) print
'
For each line, set a counter to zero.
Then look at each field (column) other than the first (the Gene ID),
and, if it is less than 3, count it.
Then, if the count is less than five, print the line.
If five or more columns have values less than 3,
skip the line (i.e., delete it).
If you need to collapse this into a single line,
you must add semicolons (;
) after the statements
(i.e., where the line breaks are in the above version):
awk ' count=0; for (i=2; i<=NF; i++) if ($i < 3) count++; if (count < 5) print; '
As I understand your question, you want
awk '
count=0
for (i=2; i<=NF; i++) if ($i < 3) count++
if (count < 5) print
'
For each line, set a counter to zero.
Then look at each field (column) other than the first (the Gene ID),
and, if it is less than 3, count it.
Then, if the count is less than five, print the line.
If five or more columns have values less than 3,
skip the line (i.e., delete it).
If you need to collapse this into a single line,
you must add semicolons (;
) after the statements
(i.e., where the line breaks are in the above version):
awk ' count=0; for (i=2; i<=NF; i++) if ($i < 3) count++; if (count < 5) print; '
edited Nov 19 at 6:57
answered Nov 19 at 4:29
Scott
6,59942650
6,59942650
this is the error message I get [lcoscoy@ln001 bin]$ awk 'count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print' RNA.txt awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error
– Sam
Nov 19 at 6:50
See edited answer.
– Scott
Nov 19 at 6:57
Hi Scott, thanks this worked perfectly
– Sam
Nov 19 at 7:15
add a comment |
this is the error message I get [lcoscoy@ln001 bin]$ awk 'count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print' RNA.txt awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error
– Sam
Nov 19 at 6:50
See edited answer.
– Scott
Nov 19 at 6:57
Hi Scott, thanks this worked perfectly
– Sam
Nov 19 at 7:15
this is the error message I get [lcoscoy@ln001 bin]$ awk 'count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print' RNA.txt awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error
– Sam
Nov 19 at 6:50
this is the error message I get [lcoscoy@ln001 bin]$ awk 'count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print' RNA.txt awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error awk: cmd. line:1: count=0 for (i=2; i<=NF; i++) if ($i < 3) count++ if (count < 5) print awk: cmd. line:1: ^ syntax error
– Sam
Nov 19 at 6:50
See edited answer.
– Scott
Nov 19 at 6:57
See edited answer.
– Scott
Nov 19 at 6:57
Hi Scott, thanks this worked perfectly
– Sam
Nov 19 at 7:15
Hi Scott, thanks this worked perfectly
– Sam
Nov 19 at 7:15
add a comment |
Sam is a new contributor. Be nice, and check out our Code of Conduct.
Sam is a new contributor. Be nice, and check out our Code of Conduct.
Sam is a new contributor. Be nice, and check out our Code of Conduct.
Sam is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482663%2fdelete-rows-where-5-or-more-columns-have-values-less-than-3%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Thank you for providing sample input. Now please add corresponding output.
– Scott
Nov 19 at 4:16
I am looking for commands to enable me create an output
– Sam
Nov 19 at 4:24