Question: Sort the 'score' value for each aligned sequence
1
gravatar for LakeWind
10 months ago by
LakeWind10
LakeWind10 wrote:

I am a new hand in the data analysis. Now I have the alignment results in .txt file, which includes subject sequence, pattern sequence, and score, as below:

subject: [1] AACGAACGCTGGCGGCATGCCTAACACATGCAAGT...GAAGTCGTAACAAGGTAGCCGTAGGGGAACCTGC 
score: 3031.58 
Global PairwiseAlignmentsSingleSubject (1 of 1)
pattern: [1] AACGAACGCTGGCGGCATGCCTAACACATGCAAGT...GAAGTCGTAACAAGGTAGCCGTAGGGGAACCTGC 
subject: [1] AATGAACGCTGGCGGCATGCCTAACACATGCAAGT...GAAGTCGTAACAAGGTAGCCGTAGGGGAACCTGC 
score: 2502.837

I plan to sort the score value for each aligned sequence and save the sorted scores in .txt files. I tried sort(), order() in R but didn't work. Could you please give me some suggestions or advice?

alignment sequence R • 285 views
ADD COMMENTlink modified 10 days ago by Biostar ♦♦ 20 • written 10 months ago by LakeWind10

Could you update your post with expected output?

ADD REPLYlink written 10 months ago by zx87546.5k
1
gravatar for Wietje
10 months ago by
Wietje180
Germany
Wietje180 wrote:

Assuming your file is loaded as a dataframe, you could give this a try (how exactly did you use order() on your data? (Could you provide the actual code you used?):

df_ordered <- df[order(df[,"score"], decreasing = TRUE), ]

This should sort your dataframe in decreasing order based on the score (make sure "score" is also the column header here). If you prefer an ascending order, just remove the "decreasing" option or set it to false.

ADD COMMENTlink modified 9 days ago by zx87546.5k • written 10 months ago by Wietje180
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1707 users visited in the last hour