How to create tabular matrix from the output of bash loop?
up vote
0
down vote
favorite
I have a bashloop that looks like below:
for f in sorted*.bam; do
echo "Counts for positive: " $f
bedtools coverage -a my_region.bed -b $f -bed -s
echo "Counts for negative: " $f
bedtools coverage -a my_region.bed -b $f -bed -S
done > >(tee total_coverage_on_each_strand.txt) 2>&1
The output I am saving as total_coverage_on_each_strand.txt
for $f=1 looks like this:
Counts for positive: sorted1.bam
reverseKF898354 0 14580 my_region 0 + 200229 14347 14580 0.9840192
Counts for negative: sorted1.bam
reverseKF898354 0 14580 my_region 0 + 305934 14320 14580 0.9821674
I was wondering if there is a way to save this in a variable instead of doing > >(tee total_coverage_on_each_strand.txt) 2>&1
. What do I need to do in above for loop so that I could get something like below instead?
sample type counts
sorted1.bam Counts for positive 200229
sorted1.bam Counts for negative 305934
bash shell loops
add a comment |
up vote
0
down vote
favorite
I have a bashloop that looks like below:
for f in sorted*.bam; do
echo "Counts for positive: " $f
bedtools coverage -a my_region.bed -b $f -bed -s
echo "Counts for negative: " $f
bedtools coverage -a my_region.bed -b $f -bed -S
done > >(tee total_coverage_on_each_strand.txt) 2>&1
The output I am saving as total_coverage_on_each_strand.txt
for $f=1 looks like this:
Counts for positive: sorted1.bam
reverseKF898354 0 14580 my_region 0 + 200229 14347 14580 0.9840192
Counts for negative: sorted1.bam
reverseKF898354 0 14580 my_region 0 + 305934 14320 14580 0.9821674
I was wondering if there is a way to save this in a variable instead of doing > >(tee total_coverage_on_each_strand.txt) 2>&1
. What do I need to do in above for loop so that I could get something like below instead?
sample type counts
sorted1.bam Counts for positive 200229
sorted1.bam Counts for negative 305934
bash shell loops
A first step: replaceecho "Counts for positive: " $f
withecho -n "$f"
– Cyrus
Nov 21 at 21:37
Why would you write> >(tee)
instead of| tee
?
– Socowi
Nov 21 at 22:18
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a bashloop that looks like below:
for f in sorted*.bam; do
echo "Counts for positive: " $f
bedtools coverage -a my_region.bed -b $f -bed -s
echo "Counts for negative: " $f
bedtools coverage -a my_region.bed -b $f -bed -S
done > >(tee total_coverage_on_each_strand.txt) 2>&1
The output I am saving as total_coverage_on_each_strand.txt
for $f=1 looks like this:
Counts for positive: sorted1.bam
reverseKF898354 0 14580 my_region 0 + 200229 14347 14580 0.9840192
Counts for negative: sorted1.bam
reverseKF898354 0 14580 my_region 0 + 305934 14320 14580 0.9821674
I was wondering if there is a way to save this in a variable instead of doing > >(tee total_coverage_on_each_strand.txt) 2>&1
. What do I need to do in above for loop so that I could get something like below instead?
sample type counts
sorted1.bam Counts for positive 200229
sorted1.bam Counts for negative 305934
bash shell loops
I have a bashloop that looks like below:
for f in sorted*.bam; do
echo "Counts for positive: " $f
bedtools coverage -a my_region.bed -b $f -bed -s
echo "Counts for negative: " $f
bedtools coverage -a my_region.bed -b $f -bed -S
done > >(tee total_coverage_on_each_strand.txt) 2>&1
The output I am saving as total_coverage_on_each_strand.txt
for $f=1 looks like this:
Counts for positive: sorted1.bam
reverseKF898354 0 14580 my_region 0 + 200229 14347 14580 0.9840192
Counts for negative: sorted1.bam
reverseKF898354 0 14580 my_region 0 + 305934 14320 14580 0.9821674
I was wondering if there is a way to save this in a variable instead of doing > >(tee total_coverage_on_each_strand.txt) 2>&1
. What do I need to do in above for loop so that I could get something like below instead?
sample type counts
sorted1.bam Counts for positive 200229
sorted1.bam Counts for negative 305934
bash shell loops
bash shell loops
asked Nov 21 at 21:33
MAPK
1,607829
1,607829
A first step: replaceecho "Counts for positive: " $f
withecho -n "$f"
– Cyrus
Nov 21 at 21:37
Why would you write> >(tee)
instead of| tee
?
– Socowi
Nov 21 at 22:18
add a comment |
A first step: replaceecho "Counts for positive: " $f
withecho -n "$f"
– Cyrus
Nov 21 at 21:37
Why would you write> >(tee)
instead of| tee
?
– Socowi
Nov 21 at 22:18
A first step: replace
echo "Counts for positive: " $f
with echo -n "$f"
– Cyrus
Nov 21 at 21:37
A first step: replace
echo "Counts for positive: " $f
with echo -n "$f"
– Cyrus
Nov 21 at 21:37
Why would you write
> >(tee)
instead of | tee
?– Socowi
Nov 21 at 22:18
Why would you write
> >(tee)
instead of | tee
?– Socowi
Nov 21 at 22:18
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2fstackoverflow.com%2fquestions%2f53420765%2fhow-to-create-tabular-matrix-from-the-output-of-bash-loop%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
A first step: replace
echo "Counts for positive: " $f
withecho -n "$f"
– Cyrus
Nov 21 at 21:37
Why would you write
> >(tee)
instead of| tee
?– Socowi
Nov 21 at 22:18