Question: (Closed) Converting a sequence to FASTA format in R
0
gravatar for ashamscsoft
3.2 years ago by
ashamscsoft10
ashamscsoft10 wrote:

When i try to convert the seq to fasta format that is without gaps and numbers in R, I get error. It s reading the file but while writing that in fasta format i get an error. Kindly help me with tis

rna-seq • 4.8k views
ADD COMMENTlink modified 3.2 years ago • written 3.2 years ago by ashamscsoft10
4

Please consider the following, they will heighten the probability you'll get a relevant answer fast:

  1. Please use a precise title. "R in bioinformatics" is extremely generic, and is of a kind people would usually avoid.
  2. Please use relevant tags. Your tag has nothing to do with your question
  3. Give us details on what you tried (with the exact commands) and what exact error you saw (with the error message). The devil is in the details.
  4. Proof read your post. This is a scientific forum, please show us that you invest some effort in both trying to solve your problem and in trying to communicate the challenge.
ADD REPLYlink written 3.2 years ago by RamRS21k

This the coding i used

############Creating a mutated sequence file
library(seqinr)
require(ade4)
library(Biostrings)
d1<-read.fasta(file = "H1.fasta")
ds1 <- d1[[1]]
write.fasta(new,names=names(x),file="sample.fasta",nbchar=60)

d2<-read.fasta(file = "sample.fasta")
ds2 <- d2[[1]]

And this s the error i get

> write.fasta(new,names=names(x),file="sample.fasta",nbchar=60)
Error in sequence[(nbchar * q + 1):l] : 
  object of type 'closure' is not subsettable

The line which i get error is started with ">"

This is the coding i tried in R nd the error what I got s attached here

ADD REPLYlink modified 3.2 years ago by geek_y9.6k • written 3.2 years ago by ashamscsoft10
1

I guess you copy-pasted code from somewhere that doesn't fit, none of the variables you are using in write.fasta is defined in the code before. new is a function, so that is why you are getting the error. Given the input, the message from R is the correct response to incorrect input. Nothing is unexpected here.

Please revise your code and check use of variables to follow the basics of programming.

ADD REPLYlink modified 3.2 years ago • written 3.2 years ago by Michael Dondrup46k

What is new and x in write.fasta ?

ADD REPLYlink written 3.2 years ago by geek_y9.6k

Hello ashamscsoft!

We believe that this post does not fit the main topic of this site.

Not a bioinformatics question. Q is lacking basic programming concepts.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink written 3.2 years ago by Michael Dondrup46k
1

Instead of closing the question or we should try to help the user formulate it better. As seen above the original poster has followed up on it. Using R to convert a sequence to FASTA format is a bioinformatics question.

ADD REPLYlink written 3.2 years ago by Istvan Albert ♦♦ 80k

I disagree to leave this open, the user has followed up but: as the code he posted shows the solution to what seems to be bioinformatics is simply lack of basic knowledge in programming, or lazy copy pasting or both. I don't think we can help the user further, because we don't know what is to be achieved here, neither do I think that we should teach basic R programming on this site. Feel free to improve the question if you know how.

ADD REPLYlink written 3.2 years ago by Michael Dondrup46k

Thank u Istvan I got help from FB

ADD REPLYlink written 3.2 years ago by ashamscsoft10

Right but this cuts both way - the same requirement that we ask people to be more considerate and graceful applies to you as well - you are to one asking for help.

ADD REPLYlink written 3.2 years ago by Istvan Albert ♦♦ 80k

Same thing ly i posted in FB too they re getting it rite?

ADD REPLYlink written 3.2 years ago by ashamscsoft10

You're digging a deeper hole. Use better language and better judgement, and maybe you'll do better next time. You'll get nowhere by being rude to people. Michael criticized your programming practice, you attacked his person - there's a huge difference there.

If you really think Facebook matches your frequency better and we are being rude to you, then there's a genuine difference in perspective. I'd like to remind you that no one - Facebook, Biostars or anywhere else - is under obligation to help you. It's just this is a scientific, professional forum and we expect a certain level of professionalism from people here.

ADD REPLYlink written 3.2 years ago by RamRS21k

Not ly me many told me tat if people re posting their questions here. Admin is insulting them like u question does not have sense nd ur copied like such stuff. Understand one thing k we re beginners not expert like u people. If we ask doubt try to help instead of insulting k.

ADD REPLYlink written 3.2 years ago by ashamscsoft10
1

"Your question seems copy-pasted" is not a personal insult. It's a question of professional ethics. There is a growing trend with people calling themselves a "beginner"/"newbie" as an excuse for not following basic etiquette. We are here to help beginners learn, but we're not here to teach beginners professionalism. Please do not attribute to us your lack of initiative and your unwillingness to learn basic etiquette.

What you are accusing us of is personal to me because I for one see a vast majority of questions that are badly phrased or lacking context created by users I can relate to - they are from my country, and I wish they became better over time. Sadly, many don't. Biostars is one of the friendliest professional communities I've seen. If you feel unwelcome here, we wish you all the best wherever you may feel welcome.

ADD REPLYlink written 3.2 years ago by RamRS21k

Thank u nd i wil disconnect from here.

ADD REPLYlink written 3.2 years ago by ashamscsoft10

Not ly me many told me tat if people re posting their questions here. Admin is insulting them like u question does not have sense nd ur copied like such stuff. Understand one thing k we re beginners not expert like u people. If we ask doubt try to help instead of insulting k.

ADD REPLYlink written 3.2 years ago by ashamscsoft10

Hello ashamscsoft!

We believe that this post does not fit the main topic of this site.

Cross posted on FB....

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink written 3.2 years ago by Michael Dondrup46k

Not ly me many told me tat if people re posting their questions here. Admin is insulting them like u question does not have sense nd ur copied like such stuff. Understand one thing k we re beginners not expert like u people. If we ask doubt try to help instead of insulting k.

ADD REPLYlink written 3.2 years ago by ashamscsoft10
2
gravatar for Michael Dondrup
3.2 years ago by
Bergen, Norway
Michael Dondrup46k wrote:

So Istvan wants me to fish in the dark, so I think I now understand what the problem is. First a hint:

Simply copypasting code doesn't take you anywhere, you need at least basic understanding of programming, I am not even saying R-programming. So please don't use code that you don't understand for your analyses.

Here are the rules that you should check and that are violated:

  • If you want to use a variable, you need to assign data to it first (like with dt, vs. x) and in many you also need to declare the variable. Unfortunately, R is not good in enforcing that, but most programming languages do.
  • Don't use reserved words or names of core functions as variable names (new, t, gc, matrix, ...), you will give yourself hell of a time trying to debug or read this code. Unfortunately, again, R has only very few reserved words and even core functions are not protected against overwriting or using for variables.
  • Values assigned to variable A (ds1) do not magically appear to be assigned to another variable B (x) unless you do some really weird stuff.

R is maybe about the worst language to choose to start learning programming (maybe alongside PHP), because it doesn't enforce any of the good programming habits. So maybe, maybe, you want something like:

write.fasta(_ds1_ , names=names(_ds1_), file="sample.fasta", nbchar=60)
ADD COMMENTlink modified 3.2 years ago • written 3.2 years ago by Michael Dondrup46k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

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