Counting number of TE in a file
2
0
Entering edit mode
9.7 years ago
yasjas ▴ 70

Hello everyone,

I am totally new in this field, I would like to count the number of for example "LINE" in my file that I copied it below(a piece of it). Does anyone know how to extract only those elements and make a count?

Thank you for your answers

           V1        V2        V3    V4            V5                 V6                V7
1      chr1    764865    765015  chr1    764975    765444           LINE
2      chr1    766165    766315  chr1    765813    766227           LINE
3      chr1    766165    766315  chr1    766266    766404           LINE
4      chr1    806905    807055  chr1    806805    807172           LINE
5      chr1    811805    811955  chr1    811640    811814  Simple_repeat
6      chr1    823425    823575  chr1    823465    823644           LINE
7      chr1    824725    824875  chr1    824336    824727            LTR
8      chr1    825805    825955  chr1    825766    825837           SINE
9      chr1    859125    859275  chr1    859231    859271 Low_complexity
10     chr1    860605    860755  chr1    860707    860770 Low_complexity
11     chr1    875645    875795  chr1    875614    875647 Low_complexity
12     chr1    875645    875795  chr1    875663    875709 Low_complexity
13     chr1    894005    894155  chr1    893930    894175           LINE
14     chr1    894585    894735  chr1    894684    894732  Simple_repeat
15     chr1    902325    902475  chr1    902408    902434 Low_complexity
16     chr1    911265    911415  chr1    911296    911338  Simple_repeat
17     chr1    934465    934615  chr1    934466    934512 Low_complexity
18     chr1    938725    938875  chr1    938758    938805            LTR
19     chr1    940705    940855  chr1    940826    940987            LTR
20     chr1    944465    944615  chr1    944204    944490           SINE
21     chr1    944465    944615  chr1    944492    944625            LTR
R • 2.1k views
ADD COMMENT
0
Entering edit mode
9.7 years ago
TriS ★ 4.7k

In R you can do it like this

m <- read.table("yourFile.txt")
sum(m$V7 == "LINE")
ADD COMMENT
0
Entering edit mode

Thank you for your answer TriS it was really helpful :-)

ADD REPLY
0
Entering edit mode
9.7 years ago
tszn1984 ▴ 100

In Linux:

grep LINE filename | wc -l
ADD COMMENT
0
Entering edit mode

Slight change: grep -cw "LINE" filename :)

ADD REPLY

Login before adding your answer.

Traffic: 1940 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6