Split a matrix into submatrices
0
0
Entering edit mode
5.1 years ago
pablo ▴ 300

Hello guys,

I want to split my matrix into several submatrices in order to compute the correlations on theses submatrices. I created an argument subset in R which takes into account the number of rows of the matrix.

# get options 

option_list = list(
        make_option(c("-s", "--subset"), type="character", default=NULL, help="Input file matrix ")
);

opt_parser= OptionParser(usage = "Usage: %prog -f [FILE]",option_list=option_list, description= "Description:")

opt = parse_args(opt_parser)

My problem is this one : for example, if I want to create submatrices which have 1000 rows each, I don't how to set this argument.

data<-read.table("/home/vipailler/PROJET_M2/raw/truelength2.prok2.uniref2.rares.tsv", h=T, row.names=1, sep="\t")

 data=data[(nrow(opt$subset))-999:opt$subset,]  ###THE PROBLEM IS HERE###

I use SLURM and arrays to compute 10 submatrices (--array 1-10) .

subset=$((SLURM_ARRAY_TASK_ID*1000))

Normally, I should obtain for the first submatrix :
subset=1*1000 #first array in the slurm code data=data[1000-999:1000,] #from the 1000-999=1st line to the 1000th line in my R code

But I get an error:

Error in oneOrDataset(X)[, parts, drop = FALSE] : indice hors limites Calls: clr ... gsi.simshape -> oneOrDataset -> gsi.plain -> is.data.frame

Any help to set this subset argument?

Bests

matrix correlat • 2.3k views
ADD COMMENT

Login before adding your answer.

Traffic: 2555 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