Delete rows where 5 or more columns have values less than 3

The name of the pictureThe name of the pictureThe name of the pictureClash 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.










share|improve this question









New contributor




Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • 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














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.










share|improve this question









New contributor




Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • 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












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.










share|improve this question









New contributor




Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 19 at 4:14









Scott

6,59942650




6,59942650






New contributor




Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 19 at 4:05









Sam

81




81




New contributor




Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • 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










  • 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










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; '





share|improve this answer






















  • 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










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Sam is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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

























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; '





share|improve this answer






















  • 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














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; '





share|improve this answer






















  • 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












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; '





share|improve this answer














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; '






share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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










Sam is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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.













 


draft saved


draft discarded














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





















































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






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay