public void writeRarifiedSpreadhseet(File filepath, boolean withReplacement, int depth) throws Exception
	{
		Random random = new Random(24231);
		int minIndex = getSampleIdWithMinCounts();
		
		
		int rarificaitonDepth = depth;
		if( depth <= 0)
		{
			depth = getCountsForSample(minIndex);
		}
		
		
		BufferedWriter writer = new BufferedWriter(new FileWriter(filepath));
		
		writer.write("sample");
		
		for( String otu : otuNames)
			writer.write("\t" + otu);
		
		writer.write("\n");
		
		for( int x=0; x < getSampleNames().size(); x++)
		{
			writer.write(getSampleNames().get(x));
			
			int[] a = new int[getOtuNames().size()];
			List<Integer> sampleList = getSamplingList(x);

			Collections.shuffle(sampleList, random);
			
			if( ! withReplacement)
			{
				for( int y=0; y < rarificaitonDepth; y++)
					a[sampleList.get(y)]++;	
			}
			else
			{
				for( int y=0; y < rarificaitonDepth; y++)
				{
					a[sampleList.get(random.nextInt(sampleList.size()))]++;
				}
			}
			
			for( int y=0; y < a.length; y++)
				writer.write("\t" + a[y]);
			
			writer.write("\n");
			
		}
		
		writer.flush();  writer.close();
	}