[R] How to access values in s4 method

2010-10-21 Thread Fahim Md
Hi
How to access the values in the output that is an object of S4 type. I tried
to access using subset ( [ ] ) but it is not allowed.
Any clue??

Thanks
-- Fahim



#My code is as follows:
require(IRanges);
query <- IRanges(c(1, 4, 9), c(5, 7, 10))
subject <- IRanges(c(2, 2, 10), c(2, 3, 12))
findOverlaps(query, subject)


Output of find overlap function is:
--
1> findOverlaps(query, tree)
An object of class "RangesMatching"
Slot "matchMatrix":
 query subject
[1,] 1   1
[2,] 1   2
[3,] 3   2

Slot "DIM":
[1] 4 3


How to access the values in the output?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] union data in column

2010-07-23 Thread Fahim Md
Is there any function/way to merge/unite the following data

  GENEID  col1  col2 col3col4
  G234064 1 0  0   0
  G234064 1 0  0   0
  G234064 1 0  0   0
  G234064 0 1  0   0
  G234065 0 1  0   0
  G234065 0 1  0   0
  G234065 0 1  0   0
  G234065 0 0  1   0
  G234065 0 0  1   0
  G234065 0 0  0   1


into
GENEID  col1  col2 col3col4
  G234064 1 1  0   0
// 1 appears in col1 and col2 above, rest are zero
  G234065 0 1  1   1
// 1 appears in col2 , 3 and 4 above.


Thanks



-- 
Fahim

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] calling a c function from R

2010-07-14 Thread Fahim Md
Thanks a lot Matt,

Just if someone like to see how I called a C function from R with files as
argumets.
For simplicity, this example is copying  the content of input file into
output file

-
  My main program is :
  source("parse.R")
  parseGBest('gbest40.seq', 'gbest40.out');  // .seq is input file, .out is
output file
---

  I wrote a wrapper function (parse.R) as follows:

  dyn.load("parse.so");
  parseGBest= function(infile, outfile)
  {
   # Do some whatever you like here
  .C("parse", infile, outfile)
  }
--
parse.c File looks like follows:

#include
#include 
#include 
#include

void adel(char **infile, char **outfile)
{

  char line[81];
   FILE *fr, *of;

  if (!(fr = fopen(*infile, "r")))
{
  fprintf(stdout, "Error while opening input file\n");
  return ;
}

  if (!(of = fopen(*outfile, "w")))
{
  fprintf(stdout, "Error while opening output file\n");
  return ;
}

  while(fgets(line, 81, fr) != NULL)
{
fputs(line, of);
}
fclose(fr);
fclose(of);
}
--

Thats it!
I saved almost a week in parsing all those genbank est files(almost 413
files).

Thanks R&C interface team.
--Fahim







On Wed, Jul 14, 2010 at 10:18 AM, Matt Shotwell  wrote:

> Fahim,
>
> Please see the Writing R Extensions manual
> http://cran.r-project.org/doc/manuals/R-exts.pdf
>
> There are simple instructions in this document under the heading "System
> and foreign language interfaces."
>
> -Matt
>
>
> On Wed, 2010-07-14 at 01:21 -0400, Fahim Md wrote:
> > Hi,
> > I am trying to call a C function, that I wrote to parse a flat file,
>  into
> > R. The argument that will go into this function is an input file that I
> need
> > to parse and write the desired output in an output file.  I used some hit
> > and trial approach but i keep on getting the "file not found" or
> > "segmentation fault" error. I know that the error is in passing the
> argument
> > but I could not solve it.
> >
> > After reading  some of the tutorials, I understood how to do this if the
> > arguments are integers or floats. I am stuck when i am trying to send the
> > files. I am attaching stub of each file.
> > Help appreciated.
> > Thanks
> >
> > ---
> > My function call would be:
> > source("parse.R")
> > parseGBest('./gbest/inFile.seq',   './gbest/outFile.out');
> > ---
> > I wrote a wrapper function (parse.R) as follows:
> >
> > dyn.load("parse.so");
> > parseGBest = function(inFile, outFile)
> > {
> > .C( "parse" , inFile , outFile);
> > }
> >
> > How to write receive the filenames in function( , ) above. and how to
> call
> > .C
> >
> > 
> > parse.c file is as below:  How to receive the argument in funcion and how
> to
> > make it compatible with my argv[ ].
> >
> >
> > void parse( int argc, char *argv[] )  //This is working as standalone C
> > program. How to receive
> >   // the above files so
> that
> > it become compatible with my argv[ ]
> > {
> >
> > FILE *fr, *of;
> > char line[81];
> >
> >
> >  if ( *argc == 3 )*/
> > {
> > if ( ( fr = fopen( argv[0], "r" )) == NULL )
> > {
> > puts( "Can't open input file.\n" );
> > exit( 0 );
> > }
> > if ( ( of = fopen( argv[1], "w" )) == NULL )
> > {
> > puts( "Output file not given.\n" );
> > }
> >   }
> >else
> > {printf("wrong usage: Try Agay!!! correct usage is:=
>  functionName
> > inputfileToParse outFileToWriteInto\n");
> >}
> > while(fgets(line, 81, fr) != NULL)
> >
> > --
> > ---
> > --
> > }
> >
> >
> >
> > Thanks again
> > Fahim
> >
> --
> Matthew S. Shotwell
> Graduate Student
> Division of Biostatistics and Epidemiology
> Medical University of South Carolina
> http://biostatmatt.com
>
>


-- 
Fahim Mohammad
Bioinforformatics Lab
University of Louisville
Louisville, KY, USA
Ph:  +1-502-409-1167

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] calling a c function from R

2010-07-13 Thread Fahim Md
Hi,
I am trying to call a C function, that I wrote to parse a flat file,  into
R. The argument that will go into this function is an input file that I need
to parse and write the desired output in an output file.  I used some hit
and trial approach but i keep on getting the "file not found" or
"segmentation fault" error. I know that the error is in passing the argument
but I could not solve it.

After reading  some of the tutorials, I understood how to do this if the
arguments are integers or floats. I am stuck when i am trying to send the
files. I am attaching stub of each file.
Help appreciated.
Thanks

---
My function call would be:
source("parse.R")
parseGBest('./gbest/inFile.seq',   './gbest/outFile.out');
---
I wrote a wrapper function (parse.R) as follows:

dyn.load("parse.so");
parseGBest = function(inFile, outFile)
{
.C( "parse" , inFile , outFile);
}

How to write receive the filenames in function( , ) above. and how to call
.C


parse.c file is as below:  How to receive the argument in funcion and how to
make it compatible with my argv[ ].


void parse( int argc, char *argv[] )  //This is working as standalone C
program. How to receive
  // the above files so that
it become compatible with my argv[ ]
{

FILE *fr, *of;
char line[81];


 if ( *argc == 3 )*/
{
if ( ( fr = fopen( argv[0], "r" )) == NULL )
{
puts( "Can't open input file.\n" );
exit( 0 );
}
if ( ( of = fopen( argv[1], "w" )) == NULL )
{
puts( "Output file not given.\n" );
}
  }
   else
{printf("wrong usage: Try Agay!!! correct usage is:=  functionName
inputfileToParse outFileToWriteInto\n");
   }
while(fgets(line, 81, fr) != NULL)

--
---
--
}



Thanks again
Fahim

-- 
Fahim Mohammad
Bioinforformatics Lab
University of Louisville
Louisville, KY, USA
Ph:  +1-502-409-1167

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Is there any function to read genbank flat files.

2010-06-16 Thread Fahim Md
Hi
I am trying to read genbank est flat files. Is there any function in R to do
that. I was looking for something similar to SeqIO.parse(input_handle,
"genbank")  in bioPython that convert the genebank sequence into fasta
sequence.
(One option is to call biopython from R but I am not familiar with python
functions so I want to avoid that and I am keeping it as last resort)
Thanks and regards.
--Fahim



-- 
Fahim Mohammad
Bioinforformatics Lab
University of Louisville
Louisville, KY, USA
Ph:  +1-502-409-1167

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] installing a package in linux

2010-05-04 Thread Fahim Md
I recently started using ubuntu 9.10 and I am using gedit editor and R
plugin for writing R code. To install any package I need to do:
$ install.packages()
 //window pop-up for mirror selection
//then another window pop up for package selection.
After this as long as I am not exiting, the function of the newly installed
packages are available.

After I exit (i use to put 'no' in 'save workspace' option) from R,  if I
want to again work in R, I have to repeat the process of package install.
This reintallation problem was not there in windows(I was using Tinn-R as
editor, I just need to put require('package-name') to use its function).

Is there anyway so that reinstallation of the package is avoided???
thanks
--Fahim

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] using BLAT in r

2010-04-10 Thread Fahim Md
Does anyone know how to use BLAT(Blast-Like alignment tool) in R?
Thanks and regards.
-- 
Fahim

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] variable three dimensional array

2010-01-05 Thread Fahim Md
I am using R for my bioinformatics research. I am dealing with a graph in
which I need to find all possible path. I was looking for some package that
solve my purpose
but all in vain. There are available algorithms but most of them find
shortest path that ignore other paths So I decided to write my own from
scratch.


I need to create a two dimensional matrix of size nXn.
The element of each entry may contain (node,edge) pair in the form of
bit-vector.

eg. (mat is the matrix)
mat[1,1] = NULL
mat[1,2] = {1, 1100}  #first entry is node vector and second
entry is edge vector
mat[1,3] = {{01000, 01001000}, {00100, 0110}} #Here there are two
node-edge pair. There can be more also, so it is variable.

In other sense it can be said that, the matrix is a 3-d matrix with a
variable third dimension.

I tried the problem with list but I was partially succesful.

Any suggestion in this regard will be highly appreciated.
thanks


---Fahim
Louisville, KY, USA

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem with paste function

2009-09-02 Thread Fahim Md
Hi there!!
 I am having trouble with *paste* function. I dont know how to proceed. I
tried many options but i failed miserably.
I am using a variable f1 to assign a string as below:
f1=dataLine[locAffyProbeID];
( the value of f1 is *244901_at* )

Then I am using the paste function
 paste("set g=", f1);

instead of getting *set g=244901_at*, I am getting *set g=23*.

I am not able to understand why it is so.
Can anyone help!!!Please..
Thanks

-- 
Mohammad Fahim

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] PRoblem with paste function

2009-09-02 Thread Fahim Md
Hi there!!!
I am having trouble with *paste* function. I dont know how to proceed. I
tried many options but i failed miserably.
I am using a variable f1 to assign a string as below:

f1=dataLine[locAffyProbeID];

 ( the value of f1 is *244901_at* )

Then I am using the paste function
 paste("set @g1=", f1);

instead of getting *...@g1=244901_at*, I am getting *set @g1=23*.

I am not able to understand why it is so.
Can anyone help!!!Please..
Thanks

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.